mirror of https://github.com/BOINC/boinc.git
Fix bugs in content-based file management system
- stray return in compute_boinc_name() - BoincJobFile::delete() was wrong - error-check DB record deletions
This commit is contained in:
parent
f5c64abac0
commit
a259991c7a
|
@ -100,11 +100,11 @@ class BoincUserSubmitApp {
|
|||
}
|
||||
static function delete_user($user_id) {
|
||||
$db = BoincDb::get();
|
||||
$db->delete_aux('user_submit_app', "user_id=$user_id");
|
||||
return $db->delete_aux('user_submit_app', "user_id=$user_id");
|
||||
}
|
||||
function update($clause) {
|
||||
$db = BoincDb::get();
|
||||
$db->update_aux('user_submit_app', "$clause where user_id=$this->user_id and app_id=$this->app_id");
|
||||
return $db->update_aux('user_submit_app', "$clause where user_id=$this->user_id and app_id=$this->app_id");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ class BoincJobFile {
|
|||
}
|
||||
function delete() {
|
||||
$db = BoincDb::get();
|
||||
$db->delete($this, 'job_file');
|
||||
return $db->delete_aux($this, 'job_file', "md5='$this->md5'");
|
||||
}
|
||||
function update($clause) {
|
||||
$db = BoincDb::get();
|
||||
|
@ -142,13 +142,13 @@ class BoincBatchFileAssoc {
|
|||
}
|
||||
function delete() {
|
||||
$db = BoincDb::get();
|
||||
$db->delete_aux('batch_file_assoc',
|
||||
return $db->delete_aux('batch_file_assoc',
|
||||
"job_file_id=$this->job_file_id and batch_id=$this->batch_id"
|
||||
);
|
||||
}
|
||||
static function delete_batch($batch_id) {
|
||||
$db = BoincDb::get();
|
||||
$db->delete_aux('batch_file_assoc',
|
||||
return $db->delete_aux('batch_file_assoc',
|
||||
"batch_id=$batch_id"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -116,6 +116,9 @@ function query_files($r) {
|
|||
$jf_id = BoincJobFile::insert(
|
||||
"(md5, create_time, delete_time) values ('$md5', $now, $delete_time)"
|
||||
);
|
||||
if (!$jf_id) {
|
||||
xml_error(-1, "query_file(): BoincJobFile::insert($md5) failed: ".BoincDb::error());
|
||||
}
|
||||
}
|
||||
// create batch association if needed
|
||||
//
|
||||
|
@ -131,7 +134,12 @@ function query_files($r) {
|
|||
}
|
||||
} else {
|
||||
if ($job_file) {
|
||||
$job_file->delete();
|
||||
$ret = $job_file->delete();
|
||||
if (!$ret) {
|
||||
xml_error(-1,
|
||||
"BoincJobFile::delete() failed: ".BoincDb::error()
|
||||
);
|
||||
}
|
||||
}
|
||||
$absent_files[] = $i;
|
||||
}
|
||||
|
@ -166,7 +174,7 @@ function upload_files($r) {
|
|||
"(md5, create_time, delete_time) values ('$md5', $now, $delete_time)"
|
||||
);
|
||||
if (!$jf_id) {
|
||||
xml_error(-1, "BoincJobFile::insert($md5) failed: ".BoincDb::error());
|
||||
xml_error(-1, "upload_files(): BoincJobFile::insert($md5) failed: ".BoincDb::error());
|
||||
}
|
||||
if ($batch_id) {
|
||||
BoincBatchFileAssoc::insert(
|
||||
|
|
|
@ -125,9 +125,11 @@ void filename_extension(const char* path, char* ext) {
|
|||
|
||||
int compute_boinc_name(string path, LOCAL_FILE& f) {
|
||||
char md5[64], ext[256];
|
||||
return md5_file(path.c_str(), md5, f.nbytes);
|
||||
int retval = md5_file(path.c_str(), md5, f.nbytes);
|
||||
if (retval) return retval;
|
||||
filename_extension(path.c_str(), ext);
|
||||
sprintf(f.boinc_name, "%s%s", md5, ext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *escape_str(const string &str) {
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
|
||||
#include "remote_submit.h"
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
const char* project_url = "http://isaac.ssl.berkeley.edu/test/";
|
||||
const char* authenticator = "157f96a018b0b2f2b466e2ce3c7f54db";
|
||||
|
||||
|
|
Loading…
Reference in New Issue