From 7d6d3af54a2fc1fb68634725eb754b22f02fd430 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Tue, 29 Oct 2019 19:05:44 +0200 Subject: Add Features: allowing lists to be sorted by modifiedAt when not in draggable mode. Bug Fix #2093: the broken should be prior to file attachment feature introduced, and tested export board is working. Thanks to whowillcare ! ( xet7 merged this pull request manually from https://github.com/wekan/wekan/pull/2756 ) Closes #2093 --- models/export.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'models/export.js') diff --git a/models/export.js b/models/export.js index a69be970..056eefdc 100644 --- a/models/export.js +++ b/models/export.js @@ -50,12 +50,18 @@ if (Meteor.isServer) { }); } +// exporter maybe is broken since Gridfs introduced, add fs and path + export class Exporter { constructor(boardId) { this._boardId = boardId; } build() { + const fs = Npm.require('fs'); + const os = Npm.require('os'); + const path = Npm.require('path'); + const byBoard = { boardId: this._boardId }; const byBoardNoLinked = { boardId: this._boardId, @@ -134,6 +140,11 @@ export class Exporter { const getBase64Data = function(doc, callback) { let buffer = new Buffer(0); // callback has the form function (err, res) {} + const tmpFile = path.join( + os.tmpdir(), + `tmpexport${process.pid}${Math.random()}`, + ); + const tmpWriteable = fs.createWriteStream(tmpFile); const readStream = doc.createReadStream(); readStream.on('data', function(chunk) { buffer = Buffer.concat([buffer, chunk]); @@ -143,8 +154,12 @@ export class Exporter { }); readStream.on('end', function() { // done + fs.unlink(tmpFile, () => { + //ignored + }); callback(null, buffer.toString('base64')); }); + readStream.pipe(tmpWriteable); }; const getBase64DataSync = Meteor.wrapAsync(getBase64Data); result.attachments = Attachments.find(byBoard) -- cgit v1.2.3-1-g7c22 From 00d581245c1fe6a01ef372ca87d8a25bc7b937e4 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Tue, 29 Oct 2019 22:02:30 +0200 Subject: Fix typo on exporting subtasks. Thanks to xiorcala ! Closes #2770 --- models/export.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'models/export.js') diff --git a/models/export.js b/models/export.js index 056eefdc..cc979ce0 100644 --- a/models/export.js +++ b/models/export.js @@ -112,7 +112,7 @@ export class Exporter { ); result.subtaskItems.push( ...Cards.find({ - parentid: card._id, + parentId: card._id, }).fetch(), ); }); -- cgit v1.2.3-1-g7c22