mirror of https://github.com/BOINC/boinc.git
don't download if md5 & sig match already
svn path=/trunk/boinc/; revision=1942
This commit is contained in:
parent
2ad9813b12
commit
ce9666f29c
|
@ -2,18 +2,18 @@
|
||||||
// Version 1.0 (the "License"); you may not use this file except in
|
// 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
|
// compliance with the License. You may obtain a copy of the License at
|
||||||
// http://boinc.berkeley.edu/license_1.0.txt
|
// http://boinc.berkeley.edu/license_1.0.txt
|
||||||
//
|
//
|
||||||
// Software distributed under the License is distributed on an "AS IS"
|
// Software distributed under the License is distributed on an "AS IS"
|
||||||
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||||
// License for the specific language governing rights and limitations
|
// License for the specific language governing rights and limitations
|
||||||
// under the License.
|
// under the License.
|
||||||
//
|
//
|
||||||
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
||||||
//
|
//
|
||||||
// The Initial Developer of the Original Code is the SETI@home project.
|
// The Initial Developer of the Original Code is the SETI@home project.
|
||||||
// Portions created by the SETI@home project are Copyright (C) 2002
|
// 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):
|
// Contributor(s):
|
||||||
//
|
//
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ private:
|
||||||
// if set, run benchmarks on client startup
|
// if set, run benchmarks on client startup
|
||||||
bool activities_suspended;
|
bool activities_suspended;
|
||||||
bool previous_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.
|
// this is needed to update GUI windows after suspension and close transfers/files.
|
||||||
int exit_after_app_start_secs;
|
int exit_after_app_start_secs;
|
||||||
// if nonzero, exit this many seconds after starting an app
|
// if nonzero, exit this many seconds after starting an app
|
||||||
|
@ -165,7 +165,7 @@ private:
|
||||||
int link_workunit(PROJECT*, WORKUNIT*);
|
int link_workunit(PROJECT*, WORKUNIT*);
|
||||||
int link_result(PROJECT*, RESULT*);
|
int link_result(PROJECT*, RESULT*);
|
||||||
int latest_version_num(char*);
|
int latest_version_num(char*);
|
||||||
int check_suspend_activities(int&);
|
void check_suspend_activities(int&);
|
||||||
int suspend_activities(int reason);
|
int suspend_activities(int reason);
|
||||||
int resume_activities();
|
int resume_activities();
|
||||||
int make_project_dirs();
|
int make_project_dirs();
|
||||||
|
|
|
@ -95,17 +95,20 @@ int verify_downloaded_file(char* pathname, FILE_INFO& file_info) {
|
||||||
pathname, file_info.file_signature, project->code_sign_key, verified
|
pathname, file_info.file_signature, project->code_sign_key, verified
|
||||||
);
|
);
|
||||||
if (retval) {
|
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;
|
return ERR_RSA_FAILED;
|
||||||
}
|
}
|
||||||
if (!verified) {
|
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;
|
return ERR_RSA_FAILED;
|
||||||
}
|
}
|
||||||
} else if (strlen(file_info.md5_cksum)) {
|
} else if (strlen(file_info.md5_cksum)) {
|
||||||
retval = md5_file(pathname, cksum, file_info.nbytes);
|
retval = md5_file(pathname, cksum, file_info.nbytes);
|
||||||
if (strcmp(cksum, file_info.md5_cksum) || retval) {
|
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;
|
return ERR_MD5_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "log_flags.h"
|
#include "log_flags.h"
|
||||||
|
#include "filesys.h"
|
||||||
|
|
||||||
// PERS_FILE_XFER represents a persistent file transfer.
|
// PERS_FILE_XFER represents a persistent file transfer.
|
||||||
// A set of URLs is given.
|
// A set of URLs is given.
|
||||||
|
@ -80,6 +81,31 @@ int PERS_FILE_XFER::start_xfer() {
|
||||||
return ERR_IDLE_PERIOD;
|
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
|
// Create a new FILE_XFER object and initialize a
|
||||||
// download or upload for the persistent file transfer
|
// download or upload for the persistent file transfer
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue