From 6d5651e53f269f248129039389b9171b0dc7133d Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Thu, 10 Mar 2022 00:20:43 +0100 Subject: [PATCH 1/5] Attachments, ensure index of cardId exists --- models/attachments.js | 2 +- server/migrations.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/models/attachments.js b/models/attachments.js index fe15b3153..4dd70eaa1 100644 --- a/models/attachments.js +++ b/models/attachments.js @@ -83,7 +83,7 @@ if (Meteor.isServer) { }); Meteor.startup(() => { - Attachments.collection._ensureIndex({ cardId: 1 }); + Attachments.collection._ensureIndex({ 'meta.cardId': 1 }); const storagePath = Attachments.storagePath(); console.log("Meteor.startup check storagePath: ", storagePath); if (!fs.existsSync(storagePath)) { diff --git a/server/migrations.js b/server/migrations.js index 3673ac198..fd61e47cd 100644 --- a/server/migrations.js +++ b/server/migrations.js @@ -1276,3 +1276,7 @@ Migrations.add('migrate-avatars-collectionFS-to-ostrioFiles', () => { readStream.pipe(writeStream); }); }); + +Migrations.add('migrate-attachment-drop-index-cardId', () => { + Attachments.collection._dropIndex({'cardId': 1}); +}); From 27ea306c1cda26b60cca8137406fe562e7bcba81 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Thu, 10 Mar 2022 00:21:03 +0100 Subject: [PATCH 2/5] Attachments count is now visible on minicard again --- client/components/cards/minicard.jade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/components/cards/minicard.jade b/client/components/cards/minicard.jade index 4ffcfb485..fbec72194 100644 --- a/client/components/cards/minicard.jade +++ b/client/components/cards/minicard.jade @@ -127,10 +127,10 @@ template(name="minicard") span.badge-icon.fa.fa-check(class="{{#if pokerState}}text-green{{/if}}") if expiredPoker span.badge-text {{ getPokerEstimation }} - if attachments.count + if attachments.length .badge span.badge-icon.fa.fa-paperclip - span.badge-text= attachments.count + span.badge-text= attachments.length if checklists.count .badge(class="{{#if checklistFinished}}is-finished{{/if}}") span.badge-icon.fa.fa-check-square-o From 46039484428bccbf13fbcc92f0a4c7786de9a1d4 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Thu, 10 Mar 2022 00:21:32 +0100 Subject: [PATCH 3/5] Global search didn't work because of wrong Attachment search --- server/publications/cards.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/publications/cards.js b/server/publications/cards.js index 456da3b67..ac20961f2 100644 --- a/server/publications/cards.js +++ b/server/publications/cards.js @@ -774,7 +774,7 @@ function findCards(sessionId, query) { Users.find({ _id: { $in: users } }, { fields: Users.safeFields }), Checklists.find({ cardId: { $in: cards.map(c => c._id) } }), ChecklistItems.find({ cardId: { $in: cards.map(c => c._id) } }), - Attachments.find({ cardId: { $in: cards.map(c => c._id) } }), + Attachments.find({ 'meta.cardId': { $in: cards.map(c => c._id) } }).cursor, CardComments.find({ cardId: { $in: cards.map(c => c._id) } }), SessionData.find({ userId, sessionId }), ]; From bfef9fc14d49c9df20582314ac6df66e58d611d8 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Thu, 10 Mar 2022 13:59:15 +0100 Subject: [PATCH 4/5] Attachment preview on card details again --- client/components/cards/attachments.jade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/components/cards/attachments.jade b/client/components/cards/attachments.jade index ef8740181..74a22f38d 100644 --- a/client/components/cards/attachments.jade +++ b/client/components/cards/attachments.jade @@ -20,7 +20,7 @@ template(name="attachmentsGalery") each attachments .attachment-item a.attachment-thumbnail.swipebox(href="{{link}}" title="{{name}}") - if isUploaded + if link if isImage img.attachment-thumbnail-img(src="{{link}}") else if($eq extension 'mp3') @@ -38,7 +38,7 @@ template(name="attachmentsGalery") else span.attachment-thumbnail-ext= extension else - span.attachment-thumbnail-ext= extension + +spinner p.attachment-details = name span.file-size ({{fileSize size}} KB) From 1f277af7223f13cea91c1928dd085c8746b30e3c Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Thu, 10 Mar 2022 23:16:40 +0100 Subject: [PATCH 5/5] remove old attachment storagePath log message --- models/attachments.js | 1 - 1 file changed, 1 deletion(-) diff --git a/models/attachments.js b/models/attachments.js index 4dd70eaa1..6d2e95f0e 100644 --- a/models/attachments.js +++ b/models/attachments.js @@ -85,7 +85,6 @@ if (Meteor.isServer) { Meteor.startup(() => { Attachments.collection._ensureIndex({ 'meta.cardId': 1 }); const storagePath = Attachments.storagePath(); - console.log("Meteor.startup check storagePath: ", storagePath); if (!fs.existsSync(storagePath)) { console.log("create storagePath because it doesn't exist: " + storagePath); fs.mkdirSync(storagePath, { recursive: true });