Commit 9013535f authored by Bernhard Link's avatar Bernhard Link

fixed bugs introuced with adding delete switch

parent 762c669f
......@@ -14,7 +14,7 @@ config.cache
config.status
debug.log
.deps
mirrorer
reprepro
*.o
.deps
old
......
......@@ -737,10 +737,10 @@ retvalue changes_add(const char *dbdir,DB *references,filesdb filesdb,const char
} else {
assert(RET_IS_OK(r));
if( verbose >= 5 ) {
fprintf(stderr,"Deleting '%s'.",changesfilename);
fprintf(stderr,"Deleting '%s'.\n",changesfilename);
}
if( unlink(changesfilename) != 0 ) {
fprintf(stderr,"Error deleting '%s': %m",changesfilename);
fprintf(stderr,"Error deleting '%s': %m\n",changesfilename);
}
}
}
......
......@@ -173,17 +173,19 @@ static retvalue copy(const char *fullfilename,const char *origfile,const char *m
}
if( RET_WAS_ERROR(r) )
return r;
if( calculatedmd5sum != NULL )
*calculatedmd5sum = md5sum;
if( strcmp(md5sum,md5expected) == 0 ) {
r = RET_OK;
} else {
unlink(fullfilename);
fprintf(stderr,"WARNING: '%s' has md5sum '%s', while '%s' was expected.\n",origfile,md5sum,md5expected);
r = RET_ERROR_WRONG_MD5;
if( md5expected != NULL ) {
if( strcmp(md5sum,md5expected) == 0 ) {
r = RET_OK;
} else {
unlink(fullfilename);
fprintf(stderr,"WARNING: '%s' has md5sum '%s', while '%s' was expected.\n",origfile,md5sum,md5expected);
r = RET_ERROR_WRONG_MD5;
}
}
if( calculatedmd5sum != NULL )
*calculatedmd5sum = md5sum;
if( calculatedmd5sum == NULL )
free(md5sum);
......@@ -197,7 +199,7 @@ static retvalue move(const char *fullfilename,const char *origfile,const char *m
r = copy(fullfilename,origfile,md5expected,md5sum);
if( RET_IS_OK(r) ) {
if( verbose > 15 ) {
fprintf(stderr,"Deleting '%s'.",origfile);
fprintf(stderr,"Deleting '%s' after copying away.\n",origfile);
}
if( unlink(origfile) != 0 ) {
fprintf(stderr,"Error deleting '%s': %m",origfile);
......
......@@ -128,8 +128,9 @@ static retvalue files_get(filesdb db,const char *filekey,char **md5sum) {
char *n;
n = strdup((const char *)data.data);
if( *md5sum == NULL )
if( n == NULL )
return RET_ERROR_OOM;
*md5sum = n;
return RET_OK;
} else if( dbret != DB_NOTFOUND ){
db->database->err(db->database, dbret, "files.db:");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment