1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-23 22:36:32 +02:00

Clipper, Desktop: Prevent race condition when download limit is reached (#10124)

This commit is contained in:
pedr
2024-03-20 08:11:57 -03:00
committed by GitHub
parent d260d0efce
commit ea29cf4e13

View File

@@ -599,6 +599,11 @@ function shimInit(options: ShimInitOptions = null) {
try {
await gunzipFile(gzipFilePath, filePath);
// Calling request.destroy() within the downloadController can cause problems.
// The response.pipe(file) will continue even after request.destroy() is called,
// potentially causing the same promise to resolve while the cleanUpOnError
// is removing the file that have been downloaded by this function.
if (request.destroyed) return;
resolve(makeResponse(response));
} catch (error) {
cleanUpOnError(error);
@@ -606,6 +611,7 @@ function shimInit(options: ShimInitOptions = null) {
await shim.fsDriver().remove(gzipFilePath);
} else {
if (request.destroyed) return;
resolve(makeResponse(response));
}
});