Skip to content

Commit 0574eec

Browse files
Hudellrodrigok
authored andcommitted
Fixed user data download file generation (#11190)
1 parent b941169 commit 0574eec

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/rocketchat-user-data-download/server/cronProcessDownloads.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,14 @@ const sendEmail = function(userId) {
319319
};
320320

321321
const makeZipFile = function(exportOperation) {
322+
createDir(zipFolder);
323+
322324
const targetFile = path.join(zipFolder, `${ exportOperation.userId }.zip`);
325+
if (fs.existsSync(targetFile)) {
326+
exportOperation.status = 'uploading';
327+
return;
328+
}
329+
323330
const output = fs.createWriteStream(targetFile);
324331

325332
exportOperation.generatedFile = targetFile;
@@ -424,14 +431,18 @@ const continueExportOperation = function(exportOperation) {
424431
});
425432

426433
if (isDownloadFinished(exportOperation)) {
434+
const targetFile = path.join(zipFolder, `${ exportOperation.userId }.zip`);
435+
if (fs.existsSync(targetFile)) {
436+
fs.unlinkSync(targetFile);
437+
}
438+
427439
exportOperation.status = 'compressing';
428440
return;
429441
}
430442
}
431443

432444
if (exportOperation.status === 'compressing') {
433445
makeZipFile(exportOperation);
434-
exportOperation.status = 'uploading';
435446
return;
436447
}
437448

0 commit comments

Comments
 (0)