delete temp file when download is redirected (#6877)

Daniel Hammerschmidt committed Mar 12, 2025 at 08:49 UTC 0d346b1d62f600438a0df2f63ab6a3cca66fe7cd
1 file changed +4 -1
pluginHandler.js
+4 -1
@@ -381,7 +381,10 @@ module.exports.pluginHandler = function (parent) {
381 }
382 var request = http.get(opts, function (response) {
383 // handle redirections with grace
384 - if (response.headers.location) return obj.installPlugin(id, version_only, response.headers.location, func);
384 + if (response.headers.location) {
385 + file.close(function () { obj.fs.unlink(file.path, function(err) { void err; }); });
386 + return obj.installPlugin(id, version_only, response.headers.location, func);
387 + }
388 response.pipe(file);
389 file.on('finish', function () {
390 file.close(function () {