From 77fbe6397ab7f33feb1cd5d76b4e1ede7cd1878a Mon Sep 17 00:00:00 2001 From: walter Date: Tue, 15 Oct 2024 15:30:29 +0800 Subject: [PATCH] [fix](http) Remove file if downloading faile is failed #41778 (#41827) cherry pick from #41778 --- be/src/http/http_client.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/be/src/http/http_client.cpp b/be/src/http/http_client.cpp index e94614788f..bf1cd751ae 100644 --- a/be/src/http/http_client.cpp +++ b/be/src/http/http_client.cpp @@ -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; }