[fix](http) Remove file if downloading faile is failed #41778 (#41827)

cherry pick from #41778
This commit is contained in:
walter
2024-10-15 15:30:29 +08:00
committed by GitHub
parent 736bb161b1
commit 77fbe6397a

View File

@ -253,7 +253,13 @@ Status HttpClient::download(const std::string& local_path) {
}
return true;
};
RETURN_IF_ERROR(execute(callback));
if (auto s = execute(callback); !s.ok()) {
status = s;
}
if (!status.ok()) {
remove(local_path.c_str());
}
return status;
}