mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Multi-File Storage.
Thanks to mfilser ! Related https://github.com/wekan/wekan/pull/4484 Merge branch 'master' into upgrade-meteor
This commit is contained in:
commit
68e8155805
29 changed files with 921 additions and 276 deletions
|
|
@ -1216,7 +1216,7 @@ Migrations.add('migrate-attachments-collectionFS-to-ostrioFiles', () => {
|
|||
cardId: fileObj.cardId,
|
||||
listId: fileObj.listId,
|
||||
swimlaneId: fileObj.swimlaneId,
|
||||
source: 'import,'
|
||||
source: 'import'
|
||||
},
|
||||
userId,
|
||||
size: fileSize,
|
||||
|
|
@ -1328,3 +1328,12 @@ Migrations.add('migrate-attachment-drop-index-cardId', () => {
|
|||
} catch (error) {
|
||||
}
|
||||
});
|
||||
|
||||
Migrations.add('migrate-attachment-migration-fix-source-import', () => {
|
||||
// there was an error at first versions, so source was import, instead of import
|
||||
Attachments.update(
|
||||
{"meta.source":"import,"},
|
||||
{$set:{"meta.source":"import"}},
|
||||
noValidateMulti
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,65 +1,24 @@
|
|||
import Attachments, { AttachmentStorage } from '/models/attachments';
|
||||
import Attachments from '/models/attachments';
|
||||
import { ObjectID } from 'bson';
|
||||
|
||||
Meteor.publish('attachmentsList', function() {
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('attachments:', AttachmentStorage.find());
|
||||
const files = AttachmentStorage.find(
|
||||
Meteor.publish('attachmentsList', function(limit) {
|
||||
const ret = Attachments.find(
|
||||
{},
|
||||
{
|
||||
fields: {
|
||||
_id: 1,
|
||||
filename: 1,
|
||||
md5: 1,
|
||||
length: 1,
|
||||
contentType: 1,
|
||||
metadata: 1,
|
||||
name: 1,
|
||||
size: 1,
|
||||
type: 1,
|
||||
meta: 1,
|
||||
path: 1,
|
||||
versions: 1,
|
||||
},
|
||||
sort: {
|
||||
filename: 1,
|
||||
name: 1,
|
||||
},
|
||||
limit: 250,
|
||||
limit: limit,
|
||||
},
|
||||
);
|
||||
const attIds = [];
|
||||
files.forEach(file => {
|
||||
attIds.push(file._id._str);
|
||||
});
|
||||
|
||||
return [
|
||||
files,
|
||||
Attachments.find({ 'copies.attachments.key': { $in: attIds } }),
|
||||
];
|
||||
});
|
||||
|
||||
Meteor.publish('orphanedAttachments', function() {
|
||||
let keys = [];
|
||||
|
||||
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,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
).cursor;
|
||||
return ret;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue