feat: acquire lock using syncMutex

This commit is contained in:
thecodrr
2021-11-18 19:40:59 +05:00
parent 4b9453d91b
commit 485f464f13
2 changed files with 4 additions and 18 deletions

View File

@@ -140,17 +140,14 @@ export default class Backup {
},
];
try {
this._db.syncer.acquireLock();
await this._db.syncer.acquireLock(async () => {
if (
await this._migrator.migrate(collections, (id) => data[id], version)
) {
await this._db.notes.repairReferences();
await this._db.notebooks.repairReferences();
}
} finally {
await this._db.syncer.releaseLock();
}
});
}
_validate(backup) {