From 59ad74ed79a8ebb297d9fcfd7a7ea5b7d8f76fcc Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Sun, 9 Aug 2020 14:07:36 -0400 Subject: [PATCH] Fixed bug where subscriptions may register the same file multiple times --- backend/db.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/db.js b/backend/db.js index 98125cf..ca1c2db 100644 --- a/backend/db.js +++ b/backend/db.js @@ -61,6 +61,10 @@ function registerFileDB(file_path, type, multiUserMode = null, sub = null) { } else { sub_db = db.get('subscriptions').find({id: sub.id}); } + if (sub_db.get('videos').find({id: file_object.id}).value()) { + logger.verbose(`Subscription video ${file_object.id} already exists, skipping DB registration.`); + return null; + } sub_db.get('videos').push(file_object).write(); }