mirror of
https://github.com/wekan/wekan.git
synced 2025-12-23 10:50:13 +01:00
Bug Fix:2093, need to clean up the temporary file
This commit is contained in:
parent
f53c624b0f
commit
2737d6b23f
1 changed files with 7 additions and 2 deletions
|
|
@ -140,9 +140,11 @@ export class Exporter {
|
||||||
const getBase64Data = function(doc, callback) {
|
const getBase64Data = function(doc, callback) {
|
||||||
let buffer = new Buffer(0);
|
let buffer = new Buffer(0);
|
||||||
// callback has the form function (err, res) {}
|
// callback has the form function (err, res) {}
|
||||||
const tmpWriteable = fs.createWriteStream(
|
const tmpFile = path.join(
|
||||||
path.join(os.tmpdir(), `tmpexport${process.pid}`),
|
os.tmpdir(),
|
||||||
|
`tmpexport${process.pid}${Math.radom()}`,
|
||||||
);
|
);
|
||||||
|
const tmpWriteable = fs.createWriteStream(tmpFile);
|
||||||
const readStream = doc.createReadStream();
|
const readStream = doc.createReadStream();
|
||||||
readStream.on('data', function(chunk) {
|
readStream.on('data', function(chunk) {
|
||||||
buffer = Buffer.concat([buffer, chunk]);
|
buffer = Buffer.concat([buffer, chunk]);
|
||||||
|
|
@ -152,6 +154,9 @@ export class Exporter {
|
||||||
});
|
});
|
||||||
readStream.on('end', function() {
|
readStream.on('end', function() {
|
||||||
// done
|
// done
|
||||||
|
fs.unlink(tmpFile, () => {
|
||||||
|
//ignored
|
||||||
|
});
|
||||||
callback(null, buffer.toString('base64'));
|
callback(null, buffer.toString('base64'));
|
||||||
});
|
});
|
||||||
readStream.pipe(tmpWriteable);
|
readStream.pipe(tmpWriteable);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue