delete temp file when download is redirected (#6877)

This commit is contained in:
Daniel Hammerschmidt 2025-03-12 08:49:35 +01:00 committed by GitHub
parent 1f83b7927a
commit 0d346b1d62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -381,7 +381,10 @@ module.exports.pluginHandler = function (parent) {
}
var request = http.get(opts, function (response) {
// handle redirections with grace
if (response.headers.location) return obj.installPlugin(id, version_only, response.headers.location, func);
if (response.headers.location) {
file.close(function () { obj.fs.unlink(file.path, function(err) { void err; }); });
return obj.installPlugin(id, version_only, response.headers.location, func);
}
response.pipe(file);
file.on('finish', function () {
file.close(function () {