Skip to content

Commit

Permalink
Remove partial failed download file
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanformigoni committed Dec 16, 2024
1 parent 54c8ff4 commit 8361efe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cmd/fetch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,14 @@ struct fetchlist_layer_ret_t
// Fetch file
cpr::Response r = cpr::Download(ofile, url, cpr::ProgressCallback{fetch_callback, reinterpret_cast<intptr_t>(&ofile)});
// Check for success
qreturn_if(r.status_code != 200, std::unexpected("Failure to fetch file '{}' with code '{}'"_fmt(path_file, r.status_code)));
if ( r.status_code != 200 )
{
// Remove partial file
ofile.close();
fs::remove(path_file);
// Return failure
return std::unexpected("Failure to fetch file '{}' with code '{}'"_fmt(path_file, r.status_code));
} // if
// Set to progress 100%
if ( send_ipc ) { ns_ipc::ipc().send(100); }
ns_log::write('i', "Download progress: 100%");
Expand Down

0 comments on commit 8361efe

Please sign in to comment.