diff --git a/checkin_notes b/checkin_notes index fb785c3d77..23ecd7ffde 100755 --- a/checkin_notes +++ b/checkin_notes @@ -13318,3 +13318,15 @@ David 12 Dec 2006 lib/ Makefile.am updater.C (new) + +David 12 Dec 2006 + - bug fixes to auto-update + - don't print spurious error message in mfile.C + + client/ + auto_update.C + client_types.C,h + file_names.C,h + scheduler_op.C + lib/ + mfile.C diff --git a/client/auto_update.C b/client/auto_update.C index 4f017af37f..75337ff5b2 100644 --- a/client/auto_update.C +++ b/client/auto_update.C @@ -44,7 +44,7 @@ int AUTO_UPDATE::parse(MIOFILE& in) { int retval; while (in.fgets(buf, 256)) { - if (match_tag(buf, "")) { + if (match_tag(buf, "")) { return 0; } else if (match_tag(buf, "")) { version.parse(in); @@ -80,6 +80,8 @@ void AUTO_UPDATE::write(MIOFILE& out) { void AUTO_UPDATE::handle_in_reply(PROJECT* proj) { char dir[256], buf[256]; int retval; + unsigned int i; + FILE_INFO* fip; if (gstate.auto_update.present) { if (!version.greater_than(gstate.auto_update.version)) { @@ -96,17 +98,26 @@ void AUTO_UPDATE::handle_in_reply(PROJECT* proj) { } project = proj; - // create version directory and prepend to file names - // - boinc_version_dir(version, dir); - retval = boinc_mkdir(dir); - if (retval) return; - gstate.auto_update = *this; - for (unsigned int i=0; iname); - } + fip = gstate.lookup_file_info(project, fref.file_name); + if (!fip) { + msg_printf(project, MSG_ERROR, "missing update file %s", fref.file_name); + return; + } + fref.file_info = fip; + fip->is_auto_update_file = true; + } + + // create version directory + // + boinc_version_dir(*project, version, dir); + retval = boinc_mkdir(dir); + if (retval) { + msg_printf(project, MSG_ERROR, "Couldn't make version dir %s", dir); + return; + } + gstate.auto_update = *this; } void AUTO_UPDATE::install() { diff --git a/client/client_types.C b/client/client_types.C index 700d1d1dc9..5ac80a5e3b 100644 --- a/client/client_types.C +++ b/client/client_types.C @@ -659,6 +659,7 @@ FILE_INFO::FILE_INFO() { signature_required = false; is_user_file = false; is_project_file = false; + is_auto_update_file = false; pers_file_xfer = NULL; result = NULL; project = NULL; diff --git a/client/client_types.h b/client/client_types.h index 311c3ef955..2997a57d6d 100644 --- a/client/client_types.h +++ b/client/client_types.h @@ -72,6 +72,7 @@ public: bool signature_required; // true iff associated with app version bool is_user_file; bool is_project_file; + bool is_auto_update_file; bool gzip_when_done; // for output files: gzip file when done, and append .gz to its name class PERS_FILE_XFER* pers_file_xfer; diff --git a/client/file_names.C b/client/file_names.C index 47cf2b92d7..11c82c1af7 100644 --- a/client/file_names.C +++ b/client/file_names.C @@ -54,9 +54,13 @@ void get_pathname(FILE_INFO* fip, char* path) { // an associated PROJECT. // if (p) { - get_project_dir(p, buf); - sprintf(path, "%s/%s", buf, fip->name); - } else { + if (fip->is_auto_update_file) { + boinc_version_dir(*p, gstate.auto_update.version, buf); + } else { + get_project_dir(p, buf); + } + sprintf(path, "%s/%s", buf, fip->name); + } else { strcpy(path, fip->name); } } @@ -279,8 +283,10 @@ int set_to_project_group(const char* path) { return 0; } -void boinc_version_dir(VERSION_INFO& vi, char* buf) { - sprintf(buf, "boinc_version_%d_%d_%d", vi.major, vi.minor, vi.release); +void boinc_version_dir(PROJECT& p, VERSION_INFO& vi, char* buf) { + char projdir[256]; + get_project_dir(&p, projdir); + sprintf(buf, "%s/boinc_version_%d_%d_%d", projdir, vi.major, vi.minor, vi.release); } bool is_version_dir(char* buf, VERSION_INFO& vi) { diff --git a/client/file_names.h b/client/file_names.h index 7ed9af0395..6df1e09bca 100644 --- a/client/file_names.h +++ b/client/file_names.h @@ -49,7 +49,7 @@ extern void get_sched_request_filename(PROJECT&, char*); extern void get_sched_reply_filename(PROJECT&, char*); extern void get_master_filename(PROJECT&, char*); extern int set_to_project_group(const char* path); -extern void boinc_version_dir(VERSION_INFO&, char*); +extern void boinc_version_dir(PROJECT&, VERSION_INFO&, char*); extern bool is_version_dir(char*, VERSION_INFO&); #define PROJECTS_DIR "projects" diff --git a/client/scheduler_op.C b/client/scheduler_op.C index 762ee5355f..f8218761e0 100644 --- a/client/scheduler_op.C +++ b/client/scheduler_op.C @@ -820,7 +820,8 @@ int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) { } else if (match_tag(buf, "")) { retval = project->parse_project_files(mf, true); } else if (match_tag(buf, "")) { - auto_update.parse(mf); + retval = auto_update.parse(mf); + if (!retval) auto_update.present = true; } else if (strlen(buf)>1){ if (log_flags.unparsed_xml) { msg_printf(0, MSG_ERROR, diff --git a/lib/mfile.C b/lib/mfile.C index eeebac6efe..b9deb52022 100644 --- a/lib/mfile.C +++ b/lib/mfile.C @@ -64,7 +64,7 @@ int MFILE::vprintf(const char* format, va_list ap) { int n, k; k = vsnprintf(buf2, BUFSIZE, format, ap); - if (k<1 || k>=BUFSIZE) { + if (k<=-1 || k>=BUFSIZE) { fprintf(stderr, "ERROR: buffer too small in MFILE::vprintf()\n"); return -1; }