don't download if md5 & sig match already

svn path=/trunk/boinc/; revision=1942
This commit is contained in:
Karl Chen 2003-08-01 21:20:20 +00:00
parent 2ad9813b12
commit ce9666f29c
3 changed files with 41 additions and 12 deletions

View File

@ -165,7 +165,7 @@ private:
int link_workunit(PROJECT*, WORKUNIT*);
int link_result(PROJECT*, RESULT*);
int latest_version_num(char*);
int check_suspend_activities(int&);
void check_suspend_activities(int&);
int suspend_activities(int reason);
int resume_activities();
int make_project_dirs();

View File

@ -95,17 +95,20 @@ int verify_downloaded_file(char* pathname, FILE_INFO& file_info) {
pathname, file_info.file_signature, project->code_sign_key, verified
);
if (retval) {
msg_printf(project, MSG_ERROR, "verify_downloaded_file(): internal error\n");
msg_printf(project, MSG_ERROR, "verify_downloaded_file(): %s: internal error\n",
pathname);
return ERR_RSA_FAILED;
}
if (!verified) {
msg_printf(project, MSG_ERROR, "verify_downloaded_file(): file not verified\n");
msg_printf(project, MSG_ERROR, "verify_downloaded_file(): %s: file not verified\n",
pathname);
return ERR_RSA_FAILED;
}
} else if (strlen(file_info.md5_cksum)) {
retval = md5_file(pathname, cksum, file_info.nbytes);
if (strcmp(cksum, file_info.md5_cksum) || retval) {
msg_printf(project, MSG_ERROR, "verify_downloaded_file(): MD5 check failed\n");
msg_printf(project, MSG_ERROR, "verify_downloaded_file(): %s: MD5 check failed\n",
pathname);
return ERR_MD5_FAILED;
}
}

View File

@ -30,6 +30,7 @@
#include "parse.h"
#include "util.h"
#include "log_flags.h"
#include "filesys.h"
// PERS_FILE_XFER represents a persistent file transfer.
// A set of URLs is given.
@ -80,6 +81,31 @@ int PERS_FILE_XFER::start_xfer() {
return ERR_IDLE_PERIOD;
}
// Does the file exist already? this could happen for example if we are
// downloading an application which exists from a previous installation,
// or if we get the same input file (which is unlikely outside the beta
// test microcosm)
if (!is_upload) {
char pathname[256];
get_pathname(fip, pathname);
double existing_size = 0;
if (!file_size(pathname, existing_size) && existing_size == fip->nbytes) {
// file exists already and has the right size
retval = verify_downloaded_file(pathname, *fip);
if (!retval) {
// signature and checksum match
retval = fip->set_permissions();
fip->status = FILE_PRESENT;
xfer_done = true;
msg_printf(
fip->project, MSG_INFO, "File %s exists already, skipping download", pathname);
return retval;
}
}
}
// Create a new FILE_XFER object and initialize a
// download or upload for the persistent file transfer
//