Skip to content

Commit

Permalink
safer file content hash handling
Browse files Browse the repository at this point in the history
  • Loading branch information
NickOvt committed Sep 16, 2024
1 parent 6515b27 commit daa9767
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions lib/attachments/gridstore-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,21 @@ class GridstoreStorage {
if (args.length > 2) {
const calculatedFileContentHash = args[2];

this.gridfs.collection(this.bucketName + '.files').findOneAndUpdate(
{
_id: hash
},
{
$set: {
'metadata.fileContentHash': calculatedFileContentHash
if (calculatedFileContentHash) {
this.gridfs.collection(this.bucketName + '.files').findOneAndUpdate(
{
_id: hash
},
{
$set: {
'metadata.fileContentHash': calculatedFileContentHash
}
},
{
returnDocument: 'after'
}
},
{
returnDocument: 'after'
}
);
);
}
}
callback(...args);
});
Expand Down

0 comments on commit daa9767

Please sign in to comment.