sync: prepare -> collector, other optimizations

This commit is contained in:
thecodrr
2020-04-16 03:04:44 +05:00
parent 1828728f77
commit 8ad2bc5457
9 changed files with 119 additions and 110 deletions

View File

@@ -0,0 +1,27 @@
class Conflicts {
/**
*
* @param {import('../index').default} db
*/
constructor(db) {
this._db = db;
}
async recalculate() {
if (this._db.notes.conflicted.length <= 0) {
await this._db.context.write("hasConflicts", false);
}
}
async check() {
let hasConflicts = await this._db.context.read("hasConflicts");
if (hasConflicts) {
const mergeConflictError = new Error(
"Merge conflicts detected. Please resolve all conflicts to continue syncing."
);
mergeConflictError.code = "MERGE_CONFLICT";
throw mergeConflictError;
}
}
}
export default Conflicts;