mirror of
https://github.com/wekan/wekan.git
synced 2025-04-22 04:57:07 -04: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) {
|
||||
let buffer = new Buffer(0);
|
||||
// callback has the form function (err, res) {}
|
||||
const tmpWriteable = fs.createWriteStream(
|
||||
path.join(os.tmpdir(), `tmpexport${process.pid}`),
|
||||
const tmpFile = path.join(
|
||||
os.tmpdir(),
|
||||
`tmpexport${process.pid}${Math.radom()}`,
|
||||
);
|
||||
const tmpWriteable = fs.createWriteStream(tmpFile);
|
||||
const readStream = doc.createReadStream();
|
||||
readStream.on('data', function(chunk) {
|
||||
buffer = Buffer.concat([buffer, chunk]);
|
||||
|
@ -152,6 +154,9 @@ export class Exporter {
|
|||
});
|
||||
readStream.on('end', function() {
|
||||
// done
|
||||
fs.unlink(tmpFile, () => {
|
||||
//ignored
|
||||
});
|
||||
callback(null, buffer.toString('base64'));
|
||||
});
|
||||
readStream.pipe(tmpWriteable);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue