Skip to content

Commit

Permalink
Merge pull request #130 from rhashimoto/update-metadata-on-xsync
Browse files Browse the repository at this point in the history
Fix #110. Ensure metadata is written on xSync.
  • Loading branch information
rhashimoto committed Nov 11, 2023
2 parents 51e1283 + bde2469 commit 180a256
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/examples/IDBBatchAtomicVFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,13 @@ export class IDBBatchAtomicVFS extends VFS.Base {
const file = this.#mapIdToFile.get(fileId);
log(`xSync ${file.path} ${flags}`);
try {
if (file.isMetadataChanged) {
// Metadata has changed so write block 0 to IndexedDB.
this.#idb.run('readwrite', async ({blocks}) => {
await blocks.put(file.block0);
});
file.isMetadataChanged = false;
}
await this.#idb.sync();
} catch (e) {
console.error(e);
Expand Down Expand Up @@ -502,6 +509,7 @@ export class IDBBatchAtomicVFS extends VFS.Base {
this.#idb.run('readwrite', async ({blocks}) => {
await blocks.put(file.block0);
});
file.isMetadataChanged = false;
} catch (e) {
console.error(e);
return VFS.SQLITE_IOERR;
Expand Down

0 comments on commit 180a256

Please sign in to comment.