client: more accurate messages when a task file is missing or wrong size

This commit is contained in:
David Anderson 2023-03-26 00:01:09 -07:00
parent 892802b957
commit e57fbb6bd4
6 changed files with 27 additions and 26 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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; i<avp->app_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;
}
}
}

View File

@ -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.

View File

@ -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

View File

@ -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";