db: improve error reporting
apk_db_add_repository does its own error reporting and does not set errno reliable. This patch also tell which repository it failed to load the index for rather than just say it failed to open "APK_INDEX.gz" which does not tell much.cute-signatures
parent
1ae6f9d972
commit
9d22718d1d
|
@ -646,7 +646,7 @@ static int apk_db_create(struct apk_database *db)
|
|||
int apk_db_open(struct apk_database *db, const char *root, unsigned int flags)
|
||||
{
|
||||
apk_blob_t blob;
|
||||
const char *apk_repos = getenv("APK_REPOS"), *msg;
|
||||
const char *apk_repos = getenv("APK_REPOS"), *msg = NULL;
|
||||
int r;
|
||||
struct apk_repository_url *repo = NULL;
|
||||
|
||||
|
@ -719,12 +719,10 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags)
|
|||
r = apk_blob_for_each_segment(blob, "\n",
|
||||
apk_db_add_repository, db);
|
||||
free(blob.ptr);
|
||||
if (r != 0) {
|
||||
msg = "Unable to load repositories";
|
||||
if (r != 0)
|
||||
goto ret_r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list_for_each_entry(repo, &apk_repository_list.list, list) {
|
||||
r = apk_db_add_repository(db, APK_BLOB_STR(repo->url));
|
||||
|
@ -740,6 +738,7 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags)
|
|||
ret_errno:
|
||||
r = -errno;
|
||||
ret_r:
|
||||
if (msg != NULL)
|
||||
apk_error("%s: %s", msg, strerror(-r));
|
||||
apk_db_close(db);
|
||||
fchdir(apk_cwd_fd);
|
||||
|
@ -1008,7 +1007,7 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t repository)
|
|||
is = apk_bstream_gunzip(apk_repository_file_open(&db->repos[r], name), 1);
|
||||
}
|
||||
if (is == NULL) {
|
||||
apk_error("Failed to open index file %s", name);
|
||||
apk_error("Failed to open index for %s", db->repos[r].url);
|
||||
return -1;
|
||||
}
|
||||
apk_db_index_read(db, is, r);
|
||||
|
|
Loading…
Reference in New Issue