Try to fix orphanedAttachments.

Thanks to Madko and xet7 !

Related #2776
This commit is contained in:
Lauri Ojansivu 2021-10-21 19:39:11 +03:00
parent c47b04493a
commit 6a06522777

View file

@ -34,6 +34,8 @@ Meteor.publish('attachmentsList', function() {
Meteor.publish('orphanedAttachments', function() { Meteor.publish('orphanedAttachments', function() {
let keys = []; let keys = [];
if (Attachments.find({}, { fields: { copies: 1 } }) !== undefined) {
Attachments.find({}, { fields: { copies: 1 } }).forEach(att => { Attachments.find({}, { fields: { copies: 1 } }).forEach(att => {
keys.push(new ObjectID(att.copies.attachments.key)); keys.push(new ObjectID(att.copies.attachments.key));
}); });
@ -57,4 +59,7 @@ Meteor.publish('orphanedAttachments', function() {
limit: 250, limit: 250,
}, },
); );
} else {
return [];
}
}); });