From e57fbb6bd454c4468a2060292358b8bd9f799d6d Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 26 Mar 2023 00:01:09 -0700 Subject: [PATCH] client: more accurate messages when a task file is missing or wrong size --- client/app_start.cpp | 17 ++++++----------- client/client_types.h | 2 +- client/cs_apps.cpp | 12 +++++++----- client/cs_files.cpp | 18 ++++++++++-------- lib/error_numbers.h | 1 + lib/str_util.cpp | 3 ++- 6 files changed, 27 insertions(+), 26 deletions(-) diff --git a/client/app_start.cpp b/client/app_start.cpp index ccfee373a9..e6d1da393c 100644 --- a/client/app_start.cpp +++ b/client/app_start.cpp @@ -540,7 +540,6 @@ int ACTIVE_TASK::start(bool test) { char cmdline[80000]; // 64KB plus some extra unsigned int i; FILE_REF fref; - FILE_INFO* fip; int retval; APP_INIT_DATA aid; #ifdef _WIN32 @@ -569,18 +568,14 @@ int ACTIVE_TASK::start(bool test) { // make sure the task files exist // - fip=0; + FILE_INFO* fip = 0; retval = gstate.task_files_present(result, true, &fip); if (retval) { - if (fip) { - snprintf( - buf, sizeof(buf), - "Input file %s missing or invalid: %s", - fip->name, boincerror(retval) - ); - } else { - safe_strcpy(buf, "Input file missing or invalid"); - } + snprintf( + buf, sizeof(buf), + "Task file %s: %s", + fip->name, boincerror(retval) + ); goto error; } diff --git a/client/client_types.h b/client/client_types.h index 5f86cb16e6..e5b6e328bb 100644 --- a/client/client_types.h +++ b/client/client_types.h @@ -153,7 +153,7 @@ struct FILE_INFO { void failure_message(std::string&); int merge_info(FILE_INFO&); int verify_file(bool, bool, bool); - bool is_size_ok(); + int check_size(); bool verify_file_certs(); int gzip(); // gzip file and add .gz to name diff --git a/client/cs_apps.cpp b/client/cs_apps.cpp index 3a82fa9de6..5c6d004940 100644 --- a/client/cs_apps.cpp +++ b/client/cs_apps.cpp @@ -233,7 +233,7 @@ int CLIENT_STATE::task_files_present( FILE_INFO* fip; unsigned int i; APP_VERSION* avp = rp->avp; - int ret = 0; + int retval, ret = 0; for (i=0; iapp_files.size(); i++) { fip = avp->app_files[i].file_info; @@ -241,9 +241,10 @@ int CLIENT_STATE::task_files_present( if (fipp) *fipp = fip; ret = ERR_FILE_MISSING; } else if (check_size) { - if (!fip->is_size_ok()) { + retval = fip->check_size(); + if (retval) { if (fipp) *fipp = fip; - ret = ERR_FILE_MISSING; + ret = retval; } } } @@ -255,9 +256,10 @@ int CLIENT_STATE::task_files_present( if (fipp) *fipp = fip; ret = ERR_FILE_MISSING; } else if (check_size) { - if (!fip->is_size_ok()) { + retval = fip->check_size(); + if (retval) { if (fipp) *fipp = fip; - ret = ERR_FILE_MISSING; + ret = retval; } } } diff --git a/client/cs_files.cpp b/client/cs_files.cpp index 8b546a9301..624fffdeb4 100644 --- a/client/cs_files.cpp +++ b/client/cs_files.cpp @@ -235,8 +235,8 @@ int FILE_INFO::verify_file( name, nbytes, size ); } - status = ERR_WRONG_SIZE; - return ERR_WRONG_SIZE; + status = ERR_FILE_WRONG_SIZE; + return ERR_FILE_WRONG_SIZE; } if (!verify_contents) return 0; @@ -466,7 +466,9 @@ bool CLIENT_STATE::create_and_delete_pers_file_xfers() { } #endif -bool FILE_INFO::is_size_ok() { +// check whether file exists and has the right size +// +int FILE_INFO::check_size() { char path[MAXPATHLEN]; get_pathname(this, path, sizeof(path)); double size; @@ -475,10 +477,10 @@ bool FILE_INFO::is_size_ok() { delete_project_owned_file(path, true); status = FILE_NOT_PRESENT; msg_printf(project, MSG_INFO, "File %s not found", path); - return false; + return ERR_FILE_MISSING; } if (gstate.global_prefs.dont_verify_images && is_image_file(path)) { - return true; + return 0; } if (nbytes && (size != nbytes)) { delete_project_owned_file(path, true); @@ -487,9 +489,9 @@ bool FILE_INFO::is_size_ok() { "File %s has wrong size: expected %.0f, got %.0f", path, nbytes, size ); - return false; + return ERR_FILE_WRONG_SIZE; } - return true; + return 0; } // for each FILE_INFO (i.e. each project file the client knows about) @@ -513,7 +515,7 @@ void CLIENT_STATE::check_file_existence() { } if (cc_config.dont_check_file_sizes) continue; if (fip->status == FILE_PRESENT) { - fip->is_size_ok(); + fip->check_size(); // If an output file disappears before it's uploaded, // flag the job as an error. diff --git a/lib/error_numbers.h b/lib/error_numbers.h index 1eae1ed45a..09db1e2055 100644 --- a/lib/error_numbers.h +++ b/lib/error_numbers.h @@ -195,6 +195,7 @@ #define ERR_TRUNCATE -218 #define ERR_WRONG_URL -219 #define ERR_DUP_NAME -220 +#define ERR_FILE_WRONG_SIZE -221 #define ERR_GETGRNAM -222 #define ERR_CHOWN -223 #define ERR_HTTP_PERMANENT -224 diff --git a/lib/str_util.cpp b/lib/str_util.cpp index 78bb2d8b44..58e92a5f35 100644 --- a/lib/str_util.cpp +++ b/lib/str_util.cpp @@ -572,7 +572,7 @@ const char* boincerror(int which_error) { case ERR_ABORTED_VIA_GUI: return "result aborted via GUI"; case ERR_INSUFFICIENT_RESOURCE: return "insufficient resources"; case ERR_RETRY: return "retry"; - case ERR_WRONG_SIZE: return "wrong size"; + case ERR_WRONG_SIZE: return "wrong buffer size"; case ERR_USER_PERMISSION: return "user permission"; case ERR_BAD_EMAIL_ADDR: return "bad email address"; case ERR_BAD_PASSWD: return "bad password"; @@ -593,6 +593,7 @@ const char* boincerror(int which_error) { case ERR_TRUNCATE: return "truncate() failed"; case ERR_WRONG_URL: return "wrong URL"; case ERR_DUP_NAME: return "coprocs with duplicate names detected"; + case ERR_FILE_WRONG_SIZE: return "file has the wrong size"; case ERR_GETGRNAM: return "getgrnam() failed"; case ERR_CHOWN: return "chown() failed"; case ERR_HTTP_PERMANENT: return "permanent HTTP error";