Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: clean temp backup folders and files

Ammar Ahmed95fe1044d6d1
diff --git a/apps/mobile/app/services/backup.ts b/apps/mobile/app/services/backup.ts
index b26dfbcdb..6001c1db2 100644
--- a/apps/mobile/app/services/backup.ts
+++ b/apps/mobile/app/services/backup.ts
@@ -202,17 +202,13 @@ async function run(
});
}
- const zipSourceFolder = `${cacheDir}/${backupFileName}`;
+ const zipSourceFolder = `${cacheDir}/backup_temp`;
const zipOutputFile =
Platform.OS === "ios"
? `${path}/${backupFileName}.nnbackupz`
: `${cacheDir}/${backupFileName}.nnbackupz`;
- try {
- if (await RNFetchBlob.fs.exists(zipSourceFolder))
- await RNFetchBlob.fs.unlink(zipSourceFolder);
- } catch (e) {}
-
+ await RNFetchBlob.fs.unlink(zipSourceFolder).catch(console.log);
await RNFetchBlob.fs.mkdir(zipSourceFolder);
const attachmentsDir = zipSourceFolder + "/attachments";
@@ -269,7 +265,13 @@ async function run(
} else {
path = zipOutputFile;
}
+
RNFetchBlob.fs.unlink(zipSourceFolder).catch(console.log);
+
+ if (Platform.OS === "android") {
+ RNFetchBlob.fs.unlink(zipOutputFile).catch(console.log);
+ }
+
updateNextBackupTime();
endProgress();
@@ -309,6 +311,11 @@ async function run(
return run(progress, context, backupType);
}
+ RNFetchBlob.fs.unlink(zipSourceFolder).catch(console.log);
+ if (Platform.OS === "android") {
+ RNFetchBlob.fs.unlink(zipOutputFile).catch(console.log);
+ }
+
DatabaseLogger.error(e);
await sleep(300);
endProgress();