summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/be_files.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/be_files.c')
-rw-r--r--lib/libalpm/be_files.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index 877bc505..adf41aa4 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -208,7 +208,7 @@ static int remove_olddir(const char *syncdbpath, alpm_list_t *dirlist)
*/
int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
{
- char *dbfile, *dbfilepath;
+ char *dbfile, *dbfilepath, *syncpath;
const char *dbpath, *syncdbpath;
alpm_list_t *newdirlist = NULL, *olddirlist = NULL;
alpm_list_t *onlynew = NULL, *onlyold = NULL;
@@ -231,14 +231,18 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
RET_ERR(PM_ERR_DB_NOT_FOUND, -1);
}
- len = strlen(db->treename) + strlen(DBEXT) + 1;
+ len = strlen(db->treename) + 4;
MALLOC(dbfile, len, RET_ERR(PM_ERR_MEMORY, -1));
- sprintf(dbfile, "%s" DBEXT, db->treename);
+ sprintf(dbfile, "%s.db", db->treename);
dbpath = alpm_option_get_dbpath();
+ len = strlen(dbpath) + 6;
+ MALLOC(syncpath, len, RET_ERR(PM_ERR_MEMORY, -1));
+ sprintf(syncpath, "%s%s", dbpath, "sync/");
- ret = _alpm_download_single_file(dbfile, db->servers, dbpath, force);
+ ret = _alpm_download_single_file(dbfile, db->servers, syncpath, force);
free(dbfile);
+ free(syncpath);
if(ret == 1) {
/* files match, do nothing */
@@ -253,9 +257,9 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
syncdbpath = _alpm_db_path(db);
/* form the path to the db location */
- len = strlen(dbpath) + strlen(db->treename) + strlen(DBEXT) + 1;
+ len = strlen(dbpath) + strlen(db->treename) + 9;
MALLOC(dbfilepath, len, RET_ERR(PM_ERR_MEMORY, -1));
- sprintf(dbfilepath, "%s%s" DBEXT, dbpath, db->treename);
+ sprintf(dbfilepath, "%ssync/%s.db", dbpath, db->treename);
if(force) {
/* if forcing update, remove the old dir and extract the db */
@@ -657,7 +661,9 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
goto error;
}
while(!feof(fp)) {
- fgets(line, 255, fp);
+ if(fgets(line, 256, fp) == NULL) {
+ break;
+ }
_alpm_strtrim(line);
if(strcmp(line, "%DEPENDS%") == 0) {
while(fgets(line, sline, fp) && strlen(_alpm_strtrim(line))) {
@@ -693,7 +699,9 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
snprintf(path, PATH_MAX, "%sdeltas", pkgpath);
if((fp = fopen(path, "r"))) {
while(!feof(fp)) {
- fgets(line, 255, fp);
+ if(fgets(line, 256, fp) == NULL) {
+ break;
+ }
_alpm_strtrim(line);
if(strcmp(line, "%DELTAS%") == 0) {
while(fgets(line, sline, fp) && strlen(_alpm_strtrim(line))) {