From 3f0f36ac5aac7c921bf81f8b90da436010ae6fb2 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 17 Feb 2017 13:51:30 -0800 Subject: [PATCH] remote file management: allow long filenames Originally, the idea for remote file management was that the physical name of a file was its md5, or jf_md5. This was changed to let the submitter choose the name. But in the DB (job_file.md5) we only kept 64 chars. Change the field name to job_file.name, and change it to varchar(255) --- db/schema.sql | 5 ++--- html/inc/submit_db.inc | 4 ++-- html/ops/db_update.php | 5 +++++ html/user/job_file.php | 8 ++++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/db/schema.sql b/db/schema.sql index 318cd0604a..810ae5dd86 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -349,12 +349,11 @@ create table user_submit_app ( primary key (user_id, app_id) ) engine = InnoDB; --- Record files present on server. --- Files are named jf_(md5) +-- Record files (created by remote file mgt) present on server. -- create table job_file ( id integer not null auto_increment, - md5 char(64) not null, + name varchar(255) not null, create_time double not null, delete_time double not null, primary key (id) diff --git a/html/inc/submit_db.inc b/html/inc/submit_db.inc index 3136324dd1..b88aa266c1 100644 --- a/html/inc/submit_db.inc +++ b/html/inc/submit_db.inc @@ -115,9 +115,9 @@ class BoincJobFile { if (!$ret) return false; return $db->insert_id(); } - static function lookup_md5($md5) { + static function lookup_name($name) { $db = BoincDb::get(); - return $db->lookup('job_file', 'BoincJobFile', "md5='$md5'"); + return $db->lookup('job_file', 'BoincJobFile', "name='$name'"); } function delete() { $db = BoincDb::get(); diff --git a/html/ops/db_update.php b/html/ops/db_update.php index df44a67f03..e81a0707d1 100644 --- a/html/ops/db_update.php +++ b/html/ops/db_update.php @@ -1027,6 +1027,10 @@ function update_1_27_2016() { do_query("alter table team add column mod_time timestamp default current_timestamp on update current_timestamp"); } +function update_2_17_2017() { + do_query("alter table job_file change md5 name varchar(255) not null"); +} + // Updates are done automatically if you use "upgrade". // // If you need to do updates manually, @@ -1073,6 +1077,7 @@ $db_updates = array ( array(27012, "update_10_8_2014"), array(27013, "update_4_15_2015"), array(27014, "update_1_27_2016"), + array(27015, "update_2_17_2017"), ); ?> diff --git a/html/user/job_file.php b/html/user/job_file.php index 6c1d1856b4..f6c88a6bfc 100644 --- a/html/user/job_file.php +++ b/html/user/job_file.php @@ -117,7 +117,7 @@ function query_files($r) { // update the delete time first to avoid race condition // with job file deleter // - $job_file = BoincJobFile::lookup_md5($fname); + $job_file = BoincJobFile::lookup_name($fname); if ($job_file && $job_file->delete_time < $delete_time) { $retval = $job_file->update("delete_time=$delete_time"); if ($retval) { @@ -131,10 +131,10 @@ function query_files($r) { $jf_id = $job_file->id; } else { $jf_id = BoincJobFile::insert( - "(md5, create_time, delete_time) values ('$fname', $now, $delete_time)" + "(name, create_time, delete_time) values ('$fname', $now, $delete_time)" ); if (!$jf_id) { - xml_error(-1, "query_file(): BoincJobFile::insert($fname) failed: ".BoincDb::error()); + xml_error(-1, "query_files(): BoincJobFile::insert($fname) failed: ".BoincDb::error()); } } // create batch association if needed @@ -233,7 +233,7 @@ function upload_files($r) { } $jf_id = BoincJobFile::insert( - "(md5, create_time, delete_time) values ('$fname', $now, $delete_time)" + "(name, create_time, delete_time) values ('$fname', $now, $delete_time)" ); if (!$jf_id) { xml_error(-1, "BoincJobFile::insert($fname) failed: ".BoincDb::error());