Move every Attachments.findOne() to the ReactiveCache

This commit is contained in:
Martin Filser 2023-02-04 00:30:55 +01:00
parent fe2015735a
commit 3fc9c6efe7
5 changed files with 30 additions and 7 deletions

View file

@ -44,7 +44,7 @@ Activities.helpers({
return ReactiveCache.getCardComment(this.commentId);
},
attachment() {
return Attachments.findOne(this.attachmentId);
return ReactiveCache.getAttachment(this.attachmentId);
},
checklist() {
return Checklists.findOne(this.checklistId);

View file

@ -151,20 +151,20 @@ if (Meteor.isServer) {
check(fileObjId, String);
check(storageDestination, String);
const fileObj = Attachments.findOne({_id: fileObjId});
const fileObj = ReactiveCache.getAttachment(fileObjId);
moveToStorage(fileObj, storageDestination, fileStoreStrategyFactory);
},
renameAttachment(fileObjId, newName) {
check(fileObjId, String);
check(newName, String);
const fileObj = Attachments.findOne({_id: fileObjId});
const fileObj = ReactiveCache.getAttachment(fileObjId);
rename(fileObj, newName, fileStoreStrategyFactory);
},
validateAttachment(fileObjId) {
check(fileObjId, String);
const fileObj = Attachments.findOne({_id: fileObjId});
const fileObj = ReactiveCache.getAttachment(fileObjId);
const isValid = Promise.await(isFileValid(fileObj, attachmentUploadMimeTypes, attachmentUploadSize, attachmentUploadExternalProgram));
if (!isValid) {
@ -177,7 +177,7 @@ if (Meteor.isServer) {
Meteor.call('validateAttachment', fileObjId);
const fileObj = Attachments.findOne({_id: fileObjId});
const fileObj = ReactiveCache.getAttachment(fileObjId);
if (fileObj) {
Meteor.defer(() => Meteor.call('moveAttachmentToStorage', fileObjId, storageDestination));

View file

@ -804,7 +804,7 @@ Cards.helpers({
cover() {
if (!this.coverId) return false;
const cover = Attachments.findOne(this.coverId);
const cover = ReactiveCache.getAttachment(this.coverId);
// if we return a cover before it is fully stored, we will get errors when we try to display it
// todo XXX we could return a default "upload pending" image in the meantime?
return cover && cover.link() && cover;