@@ -182,8 +182,8 @@ function sortBlocks(blocksByTitle, blockIndices) {
182182 ) ;
183183}
184184
185- function encodeSnapshots ( snapshotData ) {
186- const encoded = cbor . encodeOne ( snapshotData , {
185+ async function encodeSnapshots ( snapshotData ) {
186+ const encoded = await cbor . encodeAsync ( snapshotData , {
187187 omitUndefinedProperties : true ,
188188 canonical : true ,
189189 } ) ;
@@ -351,7 +351,7 @@ class Manager {
351351 this . recordSerialized ( { belongsTo, index, ...snapshot } ) ;
352352 }
353353
354- save ( ) {
354+ async save ( ) {
355355 const { dir, relFile, snapFile, snapPath, reportPath} = this ;
356356
357357 if ( this . updating && this . newBlocksByTitle . size === 0 ) {
@@ -371,15 +371,17 @@ class Manager {
371371 ) ,
372372 } ;
373373
374- const buffer = encodeSnapshots ( snapshots ) ;
374+ const buffer = await encodeSnapshots ( snapshots ) ;
375375 const reportBuffer = generateReport ( relFile , snapFile , snapshots ) ;
376376
377- fs . mkdirSync ( dir , { recursive : true } ) ;
377+ await fs . promises . mkdir ( dir , { recursive : true } ) ;
378378
379379 const temporaryFiles = [ ] ;
380380 const tmpfileCreated = file => temporaryFiles . push ( file ) ;
381- writeFileAtomic . sync ( snapPath , buffer , { tmpfileCreated} ) ;
382- writeFileAtomic . sync ( reportPath , reportBuffer , { tmpfileCreated} ) ;
381+ await Promise . all ( [
382+ writeFileAtomic ( snapPath , buffer , { tmpfileCreated} ) ,
383+ writeFileAtomic ( reportPath , reportBuffer , { tmpfileCreated} ) ,
384+ ] ) ;
383385 return {
384386 changedFiles : [ snapPath , reportPath ] ,
385387 temporaryFiles,
0 commit comments