|
@@ -34,27 +34,32 @@ Meteor.publish('attachmentsList', function() {
|
|
|
|
|
|
Meteor.publish('orphanedAttachments', function() {
|
|
Meteor.publish('orphanedAttachments', function() {
|
|
let keys = [];
|
|
let keys = [];
|
|
- Attachments.find({}, { fields: { copies: 1 } }).forEach(att => {
|
|
|
|
- keys.push(new ObjectID(att.copies.attachments.key));
|
|
|
|
- });
|
|
|
|
- keys.sort();
|
|
|
|
- keys = _.uniq(keys, true);
|
|
|
|
|
|
|
|
- return AttachmentStorage.find(
|
|
|
|
- { _id: { $nin: keys } },
|
|
|
|
- {
|
|
|
|
- fields: {
|
|
|
|
- _id: 1,
|
|
|
|
- filename: 1,
|
|
|
|
- md5: 1,
|
|
|
|
- length: 1,
|
|
|
|
- contentType: 1,
|
|
|
|
- metadata: 1,
|
|
|
|
- },
|
|
|
|
- sort: {
|
|
|
|
- filename: 1,
|
|
|
|
|
|
+ if (Attachments.find({}, { fields: { copies: 1 } }) !== undefined) {
|
|
|
|
+ Attachments.find({}, { fields: { copies: 1 } }).forEach(att => {
|
|
|
|
+ keys.push(new ObjectID(att.copies.attachments.key));
|
|
|
|
+ });
|
|
|
|
+ keys.sort();
|
|
|
|
+ keys = _.uniq(keys, true);
|
|
|
|
+
|
|
|
|
+ return AttachmentStorage.find(
|
|
|
|
+ { _id: { $nin: keys } },
|
|
|
|
+ {
|
|
|
|
+ fields: {
|
|
|
|
+ _id: 1,
|
|
|
|
+ filename: 1,
|
|
|
|
+ md5: 1,
|
|
|
|
+ length: 1,
|
|
|
|
+ contentType: 1,
|
|
|
|
+ metadata: 1,
|
|
|
|
+ },
|
|
|
|
+ sort: {
|
|
|
|
+ filename: 1,
|
|
|
|
+ },
|
|
|
|
+ limit: 250,
|
|
},
|
|
},
|
|
- limit: 250,
|
|
|
|
- },
|
|
|
|
- );
|
|
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ return [];
|
|
|
|
+ }
|
|
});
|
|
});
|