A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
core: speed up backup restore
Abdullah Atta0f2a88124b28
diff --git a/packages/core/src/database/backup.ts b/packages/core/src/database/backup.tsindex 886e7e410..6518bae57 100644--- a/packages/core/src/database/backup.ts+++ b/packages/core/src/database/backup.ts@@ -430,6 +430,7 @@ export default class Backup {}private async migrateData(data: BackupDataItem[], version: number) {+ const queue: Partial<Record<CollectionName, MaybeDeletedItem<Item>[]>> = {};for (let item of data) {// we do not want to restore deleted itemsif (@@ -521,16 +522,31 @@ export default class Backup {const collectionKey: CollectionName = itemTypeToCollectionKey[itemType];if (!collectionKey) continue;+ if (itemType === "color") {+ item.dateModified = Date.now();+ item.synced = false;+ await this.db.colors.collection.upsert(item as any);+ } else if (itemType === "tag") {+ item.dateModified = Date.now();+ item.synced = false;+ await this.db.tags.collection.upsert(item as any);+ } else {+ queue[collectionKey] = queue[collectionKey] || [];+ queue[collectionKey]?.push(item);+ }+ }++ for (const key in queue) {+ const collectionKey = key as CollectionName;const collection =collectionKey === "sessioncontent"? this.db.noteHistory.sessionContent.collection: this.db[collectionKey].collection;+ if (!collection) continue;+ const items = queue[collectionKey];+ if (!items) continue;- // items should sync immediately after getting restored- item.dateModified = Date.now();- item.synced = false;-- await collection.upsert(item as any);+ await collection.put(items as any[]);}}