Skip to content

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

core: allow deleting unuploaded attachments

Abdullah Attaead0e0107ee7
diff --git a/packages/core/src/collections/attachments.js b/packages/core/src/collections/attachments.js
index 599d093e9..0778e5790 100644
--- a/packages/core/src/collections/attachments.js
+++ b/packages/core/src/collections/attachments.js
@@ -210,7 +210,12 @@ export default class Attachments extends Collection {
if (!localOnly && !(await this._canDetach(attachment)))
throw new Error("This attachment is inside a locked note.");
- if (await this._db.fs.deleteFile(attachment.metadata.hash, localOnly)) {
+ if (
+ await this._db.fs.deleteFile(
+ attachment.metadata.hash,
+ localOnly || !attachment.dateUploaded
+ )
+ ) {
if (!localOnly) {
await this.detach(attachment);
}