diff --git a/sched/file_deleter.cpp b/sched/file_deleter.cpp index 6454d5fbd5..822e4b902a 100644 --- a/sched/file_deleter.cpp +++ b/sched/file_deleter.cpp @@ -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; }