mirror of
https://github.com/wekan/wekan.git
synced 2025-12-22 10:20:14 +01:00
Try to fix orphanedAttachments.
Thanks to Madko and xet7 ! Related #2776
This commit is contained in:
parent
c47b04493a
commit
6a06522777
1 changed files with 26 additions and 21 deletions
|
|
@ -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(
|
if (Attachments.find({}, { fields: { copies: 1 } }) !== undefined) {
|
||||||
{ _id: { $nin: keys } },
|
Attachments.find({}, { fields: { copies: 1 } }).forEach(att => {
|
||||||
{
|
keys.push(new ObjectID(att.copies.attachments.key));
|
||||||
fields: {
|
});
|
||||||
_id: 1,
|
keys.sort();
|
||||||
filename: 1,
|
keys = _.uniq(keys, true);
|
||||||
md5: 1,
|
|
||||||
length: 1,
|
return AttachmentStorage.find(
|
||||||
contentType: 1,
|
{ _id: { $nin: keys } },
|
||||||
metadata: 1,
|
{
|
||||||
|
fields: {
|
||||||
|
_id: 1,
|
||||||
|
filename: 1,
|
||||||
|
md5: 1,
|
||||||
|
length: 1,
|
||||||
|
contentType: 1,
|
||||||
|
metadata: 1,
|
||||||
|
},
|
||||||
|
sort: {
|
||||||
|
filename: 1,
|
||||||
|
},
|
||||||
|
limit: 250,
|
||||||
},
|
},
|
||||||
sort: {
|
);
|
||||||
filename: 1,
|
} else {
|
||||||
},
|
return [];
|
||||||
limit: 250,
|
}
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue