Skip to content

Commit 79aaf7e

Browse files
committed
llama-run: handle rename exception
1 parent 37cb992 commit 79aaf7e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tools/run/run.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,12 @@ class HttpClient {
417417
}
418418

419419
if (!output_file.empty()) {
420-
std::filesystem::rename(output_file_partial, output_file);
420+
try {
421+
std::filesystem::rename(output_file_partial, output_file);
422+
} catch (const std::filesystem::filesystem_error & e) {
423+
printe("Failed to rename '%s' to '%s': %s\n", output_file_partial.c_str(), output_file.c_str(), e.what());
424+
return 1;
425+
}
421426
}
422427

423428
return 0;
@@ -472,7 +477,7 @@ class HttpClient {
472477

473478
return 0;
474479
}
475-
480+
476481
void set_write_options(std::string * response_str, const File & out) {
477482
if (response_str) {
478483
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, capture_data);

0 commit comments

Comments
 (0)