mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Clipper, Desktop: Prevent race condition when download limit is reached (#10124)
This commit is contained in:
parent
d260d0efce
commit
ea29cf4e13
@ -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));
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user