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
mobile: fix restoring backup files
Ammar Ahmedfa40c539ed4f
diff --git a/apps/mobile/app/screens/settings/restore-backup/index.tsx b/apps/mobile/app/screens/settings/restore-backup/index.tsxindex 06d1985c1..3dff3dd98 100644--- a/apps/mobile/app/screens/settings/restore-backup/index.tsx+++ b/apps/mobile/app/screens/settings/restore-backup/index.tsx@@ -113,19 +113,22 @@ const restoreBackup = async (options: {await unzip(filePath, zipOutputFolder);const extractedBackupFiles = await RNFetchBlob.fs.ls(zipOutputFolder);- const extractedAttachments = await RNFetchBlob.fs.ls(- `${zipOutputFolder}/attachments`- );++ const extractedAttachments = extractedBackupFiles.includes("attachments")+ ? await RNFetchBlob.fs.ls(`${zipOutputFolder}/attachments`)+ : [];const attachmentsKeyPath: any = extractedAttachments?.find((path) => path === ".attachments_key");- const attachmentsKey = await JSON.parse(- await RNFetchBlob.fs.readFile(- `${zipOutputFolder}/attachments/${attachmentsKeyPath}`,- "utf8"- )- );+ const attachmentsKey = attachmentsKeyPath+ ? await JSON.parse(+ await RNFetchBlob.fs.readFile(+ `${zipOutputFolder}/attachments/${attachmentsKeyPath}`,+ "utf8"+ )+ )+ : undefined;let count = 0;await db.transaction(async () => {@@ -187,7 +190,7 @@ const restoreBackup = async (options: {}await deleteCacheFileByName(hash);- const copied = await RNFetchBlob.fs.cp(+ await RNFetchBlob.fs.cp(`${zipOutputFolder}/attachments/${hash}`,`${cacheDir}/${hash}`);@@ -234,12 +237,12 @@ const restoreBackup = async (options: {});});options.updateProgress(undefined);-- ToastManager.show({- heading: "Backup restored successfully"- });}+ ToastManager.show({+ heading: "Backup restored successfully"+ });+await db.initCollections();refreshAllStores();Navigation.queueRoutesForUpdate();@@ -406,8 +409,6 @@ export const RestoreBackup = () => {});}, 1000);- console.log(file);-restoreBackup({uri:Platform.OS === "android"