DC_addWUInput function is modified to receive externally generated hash for the input file. This hash is received and stored under boinc in a file with the same name and extension ".md5".

git-svn-id: svn+ssh://cvs.lpds.sztaki.hu/var/lib/svn/szdg/dcapi/trunk@2315 a7169a2c-3604-0410-bc95-c702d8d87f7a
This commit is contained in:
smith 2010-02-12 12:18:02 +00:00 committed by Adam Visegradi
parent 725f19acbc
commit 0d28e98f9f
4 changed files with 51 additions and 19 deletions

View File

@ -670,8 +670,36 @@ static int check_logical_name(DC_Workunit *wu, const char *logicalFileName)
return 0;
}
static void create_hash_file(DC_PhysicalFile *file, const char *hashString)
{
const char *hashFileExt=".md5";
GString *hashFile;
FILE *f;
if (!hashString || !file || !file->path)
return;
hashFile = g_string_new(file->path);
g_string_append(hashFile, hashFileExt);
f = fopen(hashFile->str, "w");
if (!f)
{
DC_log(LOG_ERR, "Failed to create file %s: %s", hashFile->str,strerror(errno));
g_string_free(hashFile, TRUE);
return;
}
fprintf(f, "%s", hashString);
fclose(f);
DC_log(LOG_DEBUG, "MD5 hash file \"%s\" has been created with content \"%s\".", hashFile->str, hashString);
g_string_free(hashFile, TRUE);
return;
}
int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
DC_FileMode fileMode)
DC_FileMode fileMode, const char *hashString = NULL)
{
DC_PhysicalFile *file;
char *workpath;
@ -704,6 +732,7 @@ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
{
/* Remember the file mode */
file->mode = DC_FILE_PERSISTENT;
create_hash_file(file, hashString);
break;
}
@ -719,12 +748,15 @@ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
_DC_destroyPhysicalFile(file);
return ret;
}
create_hash_file(file, hashString);
break;
case DC_FILE_VOLATILE:
ret = rename(URL, file->path);
if (!ret)
{
create_hash_file(file, hashString);
break;
}
DC_log(LOG_DEBUG, "Renaming failed for input file %s: %s; "
"falling back to copy/delete", URL, strerror(errno));
ret = _DC_copyFile(URL, file->path);
@ -736,6 +768,7 @@ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
return ret;
}
unlink(URL);
create_hash_file(file, hashString);
break;
default:
DC_log(LOG_ERR, "Invalid file mode %d", fileMode);

View File

@ -147,7 +147,7 @@ DC_Workunit *DC_createWU(const char *clientName, const char *arguments[],
/* Sets an input file for the work unit. */
int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
DC_FileMode fileMode);
DC_FileMode fileMode, const char *hashString);
/* Defines an output file for the work unit. */
int DC_addWUOutput(DC_Workunit *wu, const char *logicalFileName);

View File

@ -21,7 +21,7 @@ noinst_HEADERS = \
local_wu.h
libdcapi_local_la_SOURCES = \
local_master.c \
local_master.C \
local_events.c \
local_result.c \
local_utils.c \

View File

@ -1,14 +1,14 @@
/*
* local/local_master.c
* local/local_master.C
*
* DC-API functions of master side
*
* (c) Gabor Vida 2005-2006, Daniel Drotos, 2007
*/
/* $Id$ */
/* $Date$ */
/* $Revision$ */
/* $Id: local_master.c 2246 2009-09-08 15:28:03Z gombasg $ */
/* $Date: 2009-09-08 17:28:03 +0200 (Tue, 08 Sep 2009) $ */
/* $Revision: 2246 $ */
#ifdef HAVE_CONFIG_H
#include <config.h>
@ -503,7 +503,7 @@ static int copy_file(const char *src, const char *dst)
}
int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
DC_FileMode fileMode)
DC_FileMode fileMode, const char *hashString = NULL)
{
DC_PhysicalFile *file;
char *workpath;
@ -789,7 +789,7 @@ DC_sendWUMessage(DC_Workunit *wu, const char *message)
dn= g_string_new(wu->workdir);
g_string_append(dn, "/");
g_string_append(dn, _DC_wu_cfg(wu, cfg_master_message_box));
ret= _DC_create_message(dn->str, _DCAPI_MSG_MESSAGE, message, NULL);
ret= _DC_create_message(dn->str, (char*)_DCAPI_MSG_MESSAGE, message, NULL);
g_string_free(dn, TRUE);
return(ret);
}
@ -800,13 +800,12 @@ static struct {
char *name;
}
_DC_state_names[]= {
{ DC_WU_READY, "READY" },
{ DC_WU_RUNNING, "RUNNING" },
{ DC_WU_FINISHED, "FINISHED" },
{ DC_WU_SUSPENDED, "SUSPENDED" },
{ DC_WU_ABORTED, "ABORTED" },
{ DC_WU_UNKNOWN, "UNKNOWN" },
{ 0, NULL }
{ DC_WU_READY, (char*) "READY" },
{ DC_WU_RUNNING, (char*) "RUNNING" },
{ DC_WU_FINISHED, (char*) "FINISHED" },
{ DC_WU_SUSPENDED, (char*) "SUSPENDED" },
{ DC_WU_ABORTED, (char*) "ABORTED" },
{ DC_WU_UNKNOWN, (char*) "UNKNOWN" }
};
char *
@ -815,8 +814,8 @@ _DC_state_name(DC_WUState state)
int i;
for (i= 0; _DC_state_names[i].name; i++)
if (_DC_state_names[i].state == state)
return(_DC_state_names[i].name);
return("(unknown)");
return _DC_state_names[i].name;
return _DC_state_names[DC_WU_UNKNOWN].name;
}