summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomulus Urakagi Tsai <urakagi@gmail.com>2020-05-20 15:11:22 +0800
committerRomulus Urakagi Tsai <urakagi@gmail.com>2020-05-20 15:11:22 +0800
commit4064f3f4063136c97aa7bcbcdc18fec923934b74 (patch)
tree730f644df43608576e302cd6699534ecea4984ff
parent09ce3e464fd609b3ecc8bec5263ab06093c3a442 (diff)
downloadwekan-4064f3f4063136c97aa7bcbcdc18fec923934b74.tar.gz
wekan-4064f3f4063136c97aa7bcbcdc18fec923934b74.tar.bz2
wekan-4064f3f4063136c97aa7bcbcdc18fec923934b74.zip
Fix migrated attachment not readable bug
Remove reduandant files
-rw-r--r--atachments/attachments-gAjLYeSrtAneFBdzt-提議者電子郵件(第一波+第二波).xlsxbin29409 -> 0 bytes
-rw-r--r--client/components/cards/attachments.js5
-rw-r--r--client/lib/utils.js4
-rw-r--r--models/attachments.js16
-rw-r--r--server/migrations.js44
5 files changed, 43 insertions, 26 deletions
diff --git a/atachments/attachments-gAjLYeSrtAneFBdzt-提議者電子郵件(第一波+第二波).xlsx b/atachments/attachments-gAjLYeSrtAneFBdzt-提議者電子郵件(第一波+第二波).xlsx
deleted file mode 100644
index 4e89ac5d..00000000
--- a/atachments/attachments-gAjLYeSrtAneFBdzt-提議者電子郵件(第一波+第二波).xlsx
+++ /dev/null
Binary files differ
diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js
index 82ecabcf..81f6c6e1 100644
--- a/client/components/cards/attachments.js
+++ b/client/components/cards/attachments.js
@@ -50,7 +50,10 @@ Template.attachmentsGalery.helpers({
return Attachments.link(this, 'original', '/');
},
isUploaded() {
- return !!this.meta.uploaded;
+ return !this.meta.uploading;
+ },
+ isImage() {
+ return !!this.isImage;
},
});
diff --git a/client/lib/utils.js b/client/lib/utils.js
index d712cc73..e72f177e 100644
--- a/client/lib/utils.js
+++ b/client/lib/utils.js
@@ -70,7 +70,9 @@ Utils = {
streams: 'dynamic',
chunkSize: 'dynamic',
};
- settings.meta = {};
+ settings.meta = {
+ uploading: true
+ };
if (card.isLinkedCard()) {
settings.meta.boardId = Cards.findOne(card.linkedId).boardId;
settings.meta.cardId = card.linkedId;
diff --git a/models/attachments.js b/models/attachments.js
index 1a55cb85..03999f55 100644
--- a/models/attachments.js
+++ b/models/attachments.js
@@ -6,7 +6,7 @@ const collectionName = 'attachments2';
Attachments = new FilesCollection({
storagePath: storagePath(),
debug: false,
- allowClientCode: true,
+// allowClientCode: true,
collectionName: 'attachments2',
onAfterUpload: onAttachmentUploaded,
onBeforeRemove: onAttachmentRemoving
@@ -18,7 +18,17 @@ if (Meteor.isServer) {
});
// TODO: Permission related
- // TODO: Add Activity update
+ Attachments.allow({
+ insert() {
+ return false;
+ },
+ update() {
+ return true;
+ },
+ remove() {
+ return true;
+ }
+ });
Meteor.methods({
cloneAttachment(file, overrides) {
@@ -63,7 +73,7 @@ function storagePath(defaultPath) {
}
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') {
// Add activity about adding the attachment
Activities.insert({
diff --git a/server/migrations.js b/server/migrations.js
index 840ab170..887a60e4 100644
--- a/server/migrations.js
+++ b/server/migrations.js
@@ -80,7 +80,7 @@ Migrations.add('lowercase-board-permission', () => {
Migrations.add('change-attachments-type-for-non-images', () => {
const newTypeForNonImage = 'application/octet-stream';
Attachments.find().forEach(file => {
- if (!file.isImage()) {
+ if (!file.isImage) {
Attachments.update(
file._id,
{
@@ -1058,27 +1058,29 @@ Migrations.add('change-attachment-library', () => {
const path = `${store}/${file.name()}`;
const fd = fs.createWriteStream(path);
reader.pipe(fd);
- let opts = {
- fileName: file.name(),
- type: file.type(),
- size: file.size(),
- fileId: file._id,
- meta: {
- userId: file.userId,
- boardId: file.boardId,
- cardId: file.cardId
- }
- };
- if (file.listId) {
- opts.meta.listId = file.listId;
- }
- if (file.swimlaneId) {
- opts.meta.swimlaneId = file.swimlaneId;
- }
- Attachments.addFile(path, opts, (err, fileRef) => {
- if (err) {
- console.log('error when migrating ', fileRef.name, err);
+ reader.on('end', () => {
+ let opts = {
+ fileName: file.name(),
+ type: file.type(),
+ size: file.size(),
+ fileId: file._id,
+ meta: {
+ userId: file.userId,
+ boardId: file.boardId,
+ cardId: file.cardId
+ }
+ };
+ if (file.listId) {
+ opts.meta.listId = file.listId;
}
+ if (file.swimlaneId) {
+ opts.meta.swimlaneId = file.swimlaneId;
+ }
+ Attachments.addFile(path, opts, (err, fileRef) => {
+ if (err) {
+ console.log('error when migrating', file.name(), err);
+ }
+ });
});
});
});