Commit ddd38615 authored by Natanael Copa's avatar Natanael Copa

db: fix bug with --repository

The 'r' variable is overwritten and no longer holds the repository
number.
parent 02f9400f
...@@ -1762,7 +1762,7 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t _repository) ...@@ -1762,7 +1762,7 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t _repository)
struct apk_bstream *bs = NULL; struct apk_bstream *bs = NULL;
struct apk_repository *repo; struct apk_repository *repo;
apk_blob_t brepo, btag; apk_blob_t brepo, btag;
int r, targz = 1, tag_id = 0; int repo_num, r, targz = 1, tag_id = 0;
char buf[PATH_MAX]; char buf[PATH_MAX];
if (db->num_repos >= APK_MAX_REPOS) if (db->num_repos >= APK_MAX_REPOS)
...@@ -1780,8 +1780,8 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t _repository) ...@@ -1780,8 +1780,8 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t _repository)
tag_id = apk_db_get_tag_id(db, btag); tag_id = apk_db_get_tag_id(db, btag);
} }
r = db->num_repos++; repo_num = db->num_repos++;
repo = &db->repos[r]; repo = &db->repos[repo_num];
*repo = (struct apk_repository) { *repo = (struct apk_repository) {
.url = apk_blob_cstr(brepo), .url = apk_blob_cstr(brepo),
}; };
...@@ -1795,20 +1795,20 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t _repository) ...@@ -1795,20 +1795,20 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t _repository)
apk_cache_format_index(APK_BLOB_BUF(buf), repo); apk_cache_format_index(APK_BLOB_BUF(buf), repo);
bs = apk_bstream_from_file(db->cache_fd, buf); bs = apk_bstream_from_file(db->cache_fd, buf);
} else { } else {
db->local_repos |= BIT(r); db->local_repos |= BIT(repo_num);
bs = apk_repo_file_open(repo, db->arch, apkindex_tar_gz, buf, sizeof(buf)); bs = apk_repo_file_open(repo, db->arch, apkindex_tar_gz, buf, sizeof(buf));
} }
if (bs != NULL) if (bs != NULL) {
r = load_index(db, bs, targz, r); r = load_index(db, bs, targz, repo_num);
else } else
r = -ENOENT; r = -ENOENT;
if (r != 0) { if (r != 0) {
apk_warning("Ignoring %s: %s", buf, apk_error_str(r)); apk_warning("Ignoring %s: %s", buf, apk_error_str(r));
db->bad_repos |= BIT(r); db->bad_repos |= BIT(repo_num);
r = 0; r = 0;
} else { } else {
db->repo_tags[tag_id].allowed_repos |= BIT(r); db->repo_tags[tag_id].allowed_repos |= BIT(repo_num);
} }
return 0; return 0;
......
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