mirror of
https://github.com/wekan/wekan.git
synced 2025-12-21 18:00:12 +01:00
Fix migrated attachment not readable bug
Remove reduandant files
This commit is contained in:
parent
09ce3e464f
commit
4064f3f406
5 changed files with 43 additions and 26 deletions
Binary file not shown.
|
|
@ -50,7 +50,10 @@ Template.attachmentsGalery.helpers({
|
||||||
return Attachments.link(this, 'original', '/');
|
return Attachments.link(this, 'original', '/');
|
||||||
},
|
},
|
||||||
isUploaded() {
|
isUploaded() {
|
||||||
return !!this.meta.uploaded;
|
return !this.meta.uploading;
|
||||||
|
},
|
||||||
|
isImage() {
|
||||||
|
return !!this.isImage;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,9 @@ Utils = {
|
||||||
streams: 'dynamic',
|
streams: 'dynamic',
|
||||||
chunkSize: 'dynamic',
|
chunkSize: 'dynamic',
|
||||||
};
|
};
|
||||||
settings.meta = {};
|
settings.meta = {
|
||||||
|
uploading: true
|
||||||
|
};
|
||||||
if (card.isLinkedCard()) {
|
if (card.isLinkedCard()) {
|
||||||
settings.meta.boardId = Cards.findOne(card.linkedId).boardId;
|
settings.meta.boardId = Cards.findOne(card.linkedId).boardId;
|
||||||
settings.meta.cardId = card.linkedId;
|
settings.meta.cardId = card.linkedId;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ const collectionName = 'attachments2';
|
||||||
Attachments = new FilesCollection({
|
Attachments = new FilesCollection({
|
||||||
storagePath: storagePath(),
|
storagePath: storagePath(),
|
||||||
debug: false,
|
debug: false,
|
||||||
allowClientCode: true,
|
// allowClientCode: true,
|
||||||
collectionName: 'attachments2',
|
collectionName: 'attachments2',
|
||||||
onAfterUpload: onAttachmentUploaded,
|
onAfterUpload: onAttachmentUploaded,
|
||||||
onBeforeRemove: onAttachmentRemoving
|
onBeforeRemove: onAttachmentRemoving
|
||||||
|
|
@ -18,7 +18,17 @@ if (Meteor.isServer) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Permission related
|
// TODO: Permission related
|
||||||
// TODO: Add Activity update
|
Attachments.allow({
|
||||||
|
insert() {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
update() {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
remove() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
cloneAttachment(file, overrides) {
|
cloneAttachment(file, overrides) {
|
||||||
|
|
@ -63,7 +73,7 @@ function storagePath(defaultPath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onAttachmentUploaded(fileRef) {
|
function onAttachmentUploaded(fileRef) {
|
||||||
Attachments.update({_id:fileRef._id}, {$set: {"meta.uploaded": true}});
|
Attachments.update({_id:fileRef._id}, {$set: {"meta.uploading": false}});
|
||||||
if (!fileRef.meta.source || fileRef.meta.source !== 'import') {
|
if (!fileRef.meta.source || fileRef.meta.source !== 'import') {
|
||||||
// Add activity about adding the attachment
|
// Add activity about adding the attachment
|
||||||
Activities.insert({
|
Activities.insert({
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ Migrations.add('lowercase-board-permission', () => {
|
||||||
Migrations.add('change-attachments-type-for-non-images', () => {
|
Migrations.add('change-attachments-type-for-non-images', () => {
|
||||||
const newTypeForNonImage = 'application/octet-stream';
|
const newTypeForNonImage = 'application/octet-stream';
|
||||||
Attachments.find().forEach(file => {
|
Attachments.find().forEach(file => {
|
||||||
if (!file.isImage()) {
|
if (!file.isImage) {
|
||||||
Attachments.update(
|
Attachments.update(
|
||||||
file._id,
|
file._id,
|
||||||
{
|
{
|
||||||
|
|
@ -1058,6 +1058,7 @@ Migrations.add('change-attachment-library', () => {
|
||||||
const path = `${store}/${file.name()}`;
|
const path = `${store}/${file.name()}`;
|
||||||
const fd = fs.createWriteStream(path);
|
const fd = fs.createWriteStream(path);
|
||||||
reader.pipe(fd);
|
reader.pipe(fd);
|
||||||
|
reader.on('end', () => {
|
||||||
let opts = {
|
let opts = {
|
||||||
fileName: file.name(),
|
fileName: file.name(),
|
||||||
type: file.type(),
|
type: file.type(),
|
||||||
|
|
@ -1077,9 +1078,10 @@ Migrations.add('change-attachment-library', () => {
|
||||||
}
|
}
|
||||||
Attachments.addFile(path, opts, (err, fileRef) => {
|
Attachments.addFile(path, opts, (err, fileRef) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('error when migrating ', fileRef.name, err);
|
console.log('error when migrating', file.name(), err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue