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

@ -2,18 +2,18 @@
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://boinc.berkeley.edu/license_1.0.txt
//
//
// Software distributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
// License for the specific language governing rights and limitations
// under the License.
//
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
//
// under the License.
//
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
//
// The Initial Developer of the Original Code is the SETI@home project.
// Portions created by the SETI@home project are Copyright (C) 2002
// University of California at Berkeley. All Rights Reserved.
//
// University of California at Berkeley. All Rights Reserved.
//
// Contributor(s):
//
@ -147,7 +147,7 @@ private:
// if set, run benchmarks on client startup
bool activities_suspended;
bool previous_activities_suspended;
// if activities were suspended in the previous check_suspend();
// if activities were suspended in the previous check_suspend();
// this is needed to update GUI windows after suspension and close transfers/files.
int exit_after_app_start_secs;
// if nonzero, exit this many seconds after starting an app
@ -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
//