mirror of https://github.com/laurent22/joplin.git
Clipper, Desktop: Prevent race condition when download limit is reached (#10124)
parent
d260d0efce
commit
ea29cf4e13
|
@ -599,6 +599,11 @@ function shimInit(options: ShimInitOptions = null) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await gunzipFile(gzipFilePath, filePath);
|
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));
|
resolve(makeResponse(response));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
cleanUpOnError(error);
|
cleanUpOnError(error);
|
||||||
|
@ -606,6 +611,7 @@ function shimInit(options: ShimInitOptions = null) {
|
||||||
|
|
||||||
await shim.fsDriver().remove(gzipFilePath);
|
await shim.fsDriver().remove(gzipFilePath);
|
||||||
} else {
|
} else {
|
||||||
|
if (request.destroyed) return;
|
||||||
resolve(makeResponse(response));
|
resolve(makeResponse(response));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue