file_deleter:

in do_pass() delete result/output files first. This allows
    to possibly augment the DB selection "clause" before processing
    workunit/input files
This commit is contained in:
Bernd Machenschalk 2014-06-03 06:39:01 +02:00
parent f7472149bd
commit 5ea8a09049
1 changed files with 50 additions and 49 deletions

View File

@ -316,6 +316,56 @@ bool do_pass(bool retry_error) {
sprintf(buf, " and appid = %d ", appid);
strcat(clause, buf);
}
sprintf(buf,
"where file_delete_state=%d %s limit %d",
retry_error?FILE_DELETE_ERROR:FILE_DELETE_READY,
clause, RESULTS_PER_ENUM
);
while (do_output_files) {
retval = result.enumerate(buf);
if (retval) {
if (retval != ERR_DB_NOT_FOUND) {
log_messages.printf(MSG_DEBUG, "DB connection lost, exiting\n");
exit(0);
}
break;
}
if (preserve_result_files) {
retval = 0;
} else {
retval = result_delete_files(result);
}
if (retval) {
new_state = FILE_DELETE_ERROR;
log_messages.printf(MSG_CRITICAL,
"[RESULT#%u] file deletion failed: %s\n", result.id, boincerror(retval)
);
} else {
new_state = FILE_DELETE_DONE;
}
if (new_state != result.file_delete_state) {
sprintf(buf, "file_delete_state=%d", new_state);
if (dry_run) {
retval = 0;
} else {
retval = result.update_field(buf);
}
if (retval) {
log_messages.printf(MSG_CRITICAL,
"[RESULT#%u] update failed: %s\n", result.id, boincerror(retval)
);
} else {
log_messages.printf(MSG_DEBUG,
"[RESULT#%u] file_delete_state updated\n", result.id
);
did_something = true;
}
}
}
if (xml_doc_like) {
strcat(clause, " and xml_doc like '");
strcat(clause, xml_doc_like);
@ -370,55 +420,6 @@ bool do_pass(bool retry_error) {
}
}
sprintf(buf,
"where file_delete_state=%d %s limit %d",
retry_error?FILE_DELETE_ERROR:FILE_DELETE_READY,
clause, RESULTS_PER_ENUM
);
while (do_output_files) {
retval = result.enumerate(buf);
if (retval) {
if (retval != ERR_DB_NOT_FOUND) {
log_messages.printf(MSG_DEBUG, "DB connection lost, exiting\n");
exit(0);
}
break;
}
if (preserve_result_files) {
retval = 0;
} else {
retval = result_delete_files(result);
}
if (retval) {
new_state = FILE_DELETE_ERROR;
log_messages.printf(MSG_CRITICAL,
"[RESULT#%u] file deletion failed: %s\n", result.id, boincerror(retval)
);
} else {
new_state = FILE_DELETE_DONE;
}
if (new_state != result.file_delete_state) {
sprintf(buf, "file_delete_state=%d", new_state);
if (dry_run) {
retval = 0;
} else {
retval = result.update_field(buf);
}
if (retval) {
log_messages.printf(MSG_CRITICAL,
"[RESULT#%u] update failed: %s\n", result.id, boincerror(retval)
);
} else {
log_messages.printf(MSG_DEBUG,
"[RESULT#%u] file_delete_state updated\n", result.id
);
did_something = true;
}
}
}
return did_something;
}