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
web: use single transaction for importing a backup
Abdullah Atta9bea47e35816
diff --git a/apps/web/src/common/index.ts b/apps/web/src/common/index.tsindex e6da8c6d1..b2e102e3a 100644--- a/apps/web/src/common/index.ts+++ b/apps/web/src/common/index.ts@@ -190,30 +190,33 @@ export async function restoreBackupFile(backupFile: File) {}if (!isValid) throw new Error("Invalid backup.");- for (const entry of entries) {- const backup = JSON.parse(await entry.text());- if (backup.encrypted) {- if (!cachedPassword && !cachedKey) {- const result = await showBackupPasswordDialog(- async ({ password, key }) => {- if (!password && !key) return false;- await db.backup?.import(backup, password, key);- cachedPassword = password;- cachedKey = key;- return true;- }- );- if (!result) break;- } else await db.backup?.import(backup, cachedPassword, cachedKey);- } else {- await db.backup?.import(backup);- }+ await db.transaction(async () => {+ for (const entry of entries) {+ const backup = JSON.parse(await entry.text());+ if (backup.encrypted) {+ if (!cachedPassword && !cachedKey) {+ const result = await showBackupPasswordDialog(+ async ({ password, key }) => {+ if (!password && !key) return false;+ await db.backup?.import(backup, password, key);+ cachedPassword = password;+ cachedKey = key;+ return true;+ }+ );+ if (!result) break;+ } else await db.backup?.import(backup, cachedPassword, cachedKey);+ } else {+ await db.backup?.import(backup);+ }- report({- text: `Processed ${entry.name}`,- current: filesProcessed++- });- }+ report({+ text: `Processed ${entry.name}`,+ current: filesProcessed++,+ total: entries.length+ });+ }+ });await db.initCollections();}});