mirror of
https://github.com/outline/outline.git
synced 2026-12-03 10:00:13 +03:00
Remove temporary files after processing (#5456)
Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
1 parent
8d69de1be0
commit
a094087342
1 file changed
+9
-1
@@ -40,6 +40,8 @@ export default abstract class ExportTask extends BaseTask<Props> {
|
||||
},
|
||||
});
|
||||
|
||||
let filePath: string | undefined;
|
||||
|
||||
try {
|
||||
Logger.info("task", `ExportTask processing data for ${fileOperationId}`, {
|
||||
includeAttachments: fileOperation.includeAttachments,
|
||||
@@ -49,7 +51,7 @@ export default abstract class ExportTask extends BaseTask<Props> {
|
||||
state: FileOperationState.Creating,
|
||||
});
|
||||
|
||||
const filePath = await this.export(collections, fileOperation);
|
||||
filePath = await this.export(collections, fileOperation);
|
||||
|
||||
Logger.info("task", `ExportTask uploading data for ${fileOperationId}`);
|
||||
|
||||
@@ -95,6 +97,12 @@ export default abstract class ExportTask extends BaseTask<Props> {
|
||||
}).schedule();
|
||||
}
|
||||
throw error;
|
||||
} finally {
|
||||
if (filePath) {
|
||||
void fs.promises.unlink(filePath).catch((error) => {
|
||||
Logger.error(`Failed to delete temporary file ${filePath}`, error);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user