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: never delete image & pdf attachments
Abdullah Attab4d3662897cd
diff --git a/apps/web/src/interfaces/fs.ts b/apps/web/src/interfaces/fs.tsindex 27ed17c48..daf87b0fc 100644--- a/apps/web/src/interfaces/fs.ts+++ b/apps/web/src/interfaces/fs.ts@@ -300,9 +300,8 @@ async function uploadFile(filename: string, requestOptions: RequestOptions) {});await fileHandle.addAdditionalData("uploaded", true);- // Keep the images cached; delete everything else.- if (!fileHandle.file.type?.startsWith("image/")) {- console.log("DELETING FILE", fileHandle);++ if (isAttachmentDeletable(fileHandle.file.type)) {await streamablefs.deleteFile(filename);}await checkUpload(filename);@@ -444,7 +443,8 @@ async function saveFile(filename: string, fileMetadata: FileMetadata) {const decrypted = await decryptFile(filename, fileMetadata);if (decrypted) saveAs(decrypted, getFileNameWithExtension(name, type));- if (isUploaded) await streamablefs.deleteFile(filename);+ if (isUploaded && isAttachmentDeletable(type))+ await streamablefs.deleteFile(filename);}async function deleteFile(filename: string, requestOptions: RequestOptions) {@@ -506,6 +506,10 @@ const FS = {};export default FS;+function isAttachmentDeletable(type: string) {+ return !type.startsWith("image/") && !type.startsWith("application/pdf");+}+function isSuccessStatusCode(statusCode: number) {return statusCode >= 200 && statusCode <= 299;}