mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
web: never delete image & pdf attachments
This commit is contained in:
committed by
Abdullah Atta
parent
675e1e2c6f
commit
b4d3662897
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user