From e3afdec59d14018b15f60f3e07d93f3cac369f45 Mon Sep 17 00:00:00 2001 From: Nikolai Ovtsinnikov Date: Fri, 13 Sep 2024 15:44:51 +0300 Subject: [PATCH] create stream during the try to store. otherwise getting stuck --- lib/attachments/gridstore-storage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/attachments/gridstore-storage.js b/lib/attachments/gridstore-storage.js index f62c3b16..b859f9ef 100644 --- a/lib/attachments/gridstore-storage.js +++ b/lib/attachments/gridstore-storage.js @@ -15,8 +15,6 @@ const FEATURE_DECODE_ATTACHMENTS = true; const ORPHANED_ATTACHMENTS_DELAY = 24 * 3600 * 1000; const MAX_ORPHANED_ATTACHMENTS = 1000; -let fileHashCalculator = new FileHashCalculatorStream(); - class GridstoreStorage { constructor(options) { this.bucketName = (options.options && options.options.bucket) || 'attachments'; @@ -191,6 +189,8 @@ class GridstoreStorage { return; } + let fileHashCalculator = new FileHashCalculatorStream(); + this.gridfs.collection(this.bucketName + '.files').findOneAndUpdate( { _id: hash