Commit 4a931e5b authored by Bernhard Link's avatar Bernhard Link

changed syntax of packages_get to return errors gratefully

parent 6bdf1ae4
......@@ -175,10 +175,9 @@ retvalue binaries_lookforold( DB *pkgs,const char *name, struct strlist *files)
char *oldchunk;
retvalue r;
// TODO: why does packages_get return something else than a retvalue?
oldchunk = packages_get(pkgs,name);
if( oldchunk == NULL ) {
return RET_NOTHING;
r = packages_get(pkgs,name,&oldchunk);
if( !RET_IS_OK(r) ) {
return r;
}
r = binaries_parse_getfiles(oldchunk,files);
free(oldchunk);
......@@ -201,10 +200,9 @@ retvalue binaries_lookforolder(
&& newversion != NULL && oldversion != NULL
&& oldfilekeys != NULL );
// TODO: why does packages_get return something else than a retvalue?
oldchunk = packages_get(packages,packagename);
if( oldchunk == NULL ) {
return RET_NOTHING;
r = packages_get(packages,packagename,&oldchunk);
if( !RET_IS_OK(r) ) {
return r;
}
r = binaries_parse_chunk(oldchunk,NULL,NULL,NULL,NULL,&ov);
......
......@@ -123,7 +123,7 @@ retvalue packages_add(DB *packagesdb,const char *package,const char *chunk) {
}
/* get the saved chunk from the database */
char *packages_get(DB *packagesdb,const char *package) {
retvalue packages_get(DB *packagesdb,const char *package,char **chunk) {
int dbret;
DBT key,data;
......@@ -131,12 +131,19 @@ char *packages_get(DB *packagesdb,const char *package) {
CLEARDBT(data);
if( (dbret = packagesdb->get(packagesdb, NULL, &key, &data, 0)) == 0){
return strdup(data.data);
char *c;
c = strdup(data.data);
if( c == NULL )
return RET_ERROR_OOM;
else {
*chunk = c;
return RET_OK;
}
} else if( dbret == DB_NOTFOUND ){
return NULL;
return RET_NOTHING;
} else {
packagesdb->err(packagesdb, dbret, "packages.db:");
return NULL;
return RET_DBERR(dbret);
}
}
......
......@@ -23,8 +23,9 @@ retvalue packages_add(DB *packagsdb,const char *package,const char *chunk);
retvalue packages_replace(DB *packagsdb,const char *package,const char *chunk);
/* remove a given chunk from the database */
retvalue packages_remove(DB *filesdb,const char *package);
/* get the saved chunk from the database */
char *packages_get(DB *packagesdb,const char *package);
/* get the saved chunk from the database,
* returns RET_NOTHING, if there is none*/
retvalue packages_get(DB *packagesdb,const char *package,char **chunk);
/* check for existance of the given version of a package in the arch,
* > 0 found
......
......@@ -280,10 +280,9 @@ retvalue sources_lookforold(
char *oldchunk;
retvalue r;
// TODO: why does packages_get return something else than a retvalue?
oldchunk = packages_get(packages,packagename);
if( oldchunk == NULL ) {
return RET_NOTHING;
r = packages_get(packages,packagename,&oldchunk);
if( !RET_IS_OK(r) ) {
return r;
}
r = sources_parse_getfiles(oldchunk,oldfiles);
free(oldchunk);
......@@ -305,10 +304,9 @@ retvalue sources_lookforolder(
assert(oldversion != NULL && newversion != NULL);
// TODO: why does packages_get return something else than a retvalue?
oldchunk = packages_get(packages,packagename);
if( oldchunk == NULL ) {
return RET_NOTHING;
r = packages_get(packages,packagename,&oldchunk);
if( !RET_IS_OK(r) ) {
return r;
}
r = sources_parse_chunk(oldchunk,NULL,&ov,NULL,NULL);
......
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