Skip to content

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

feat: add function to check if an attachment with hash exists

thecodrr54e238d9da36
diff --git a/packages/core/collections/attachments.js b/packages/core/collections/attachments.js
index 7af692487..472ba4f4c 100644
--- a/packages/core/collections/attachments.js
+++ b/packages/core/collections/attachments.js
@@ -95,6 +95,11 @@ export default class Attachments extends Collection {
);
}
+ exists(hash) {
+ const attachment = this.all.find((a) => a.metadata.hash === hash);
+ return !!attachment;
+ }
+
async read(hash) {
const attachment = this.all.find((a) => a.metadata.hash === hash);
if (!attachment) return;