summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2012-02-22 09:52:28 +0200
committerTimo Teräs <timo.teras@iki.fi>2012-02-22 09:52:28 +0200
commit8e5c040ffd7813b62618f757c11778bfda97a5e0 (patch)
tree5689abefa922757c634af30c4ab03348420269e2 /src/database.c
parenta7500a9df53edb81c2995486ba16f5f71579241e (diff)
downloadapk-tools-8e5c040ffd7813b62618f757c11778bfda97a5e0.tar.gz
apk-tools-8e5c040ffd7813b62618f757c11778bfda97a5e0.tar.bz2
apk-tools-8e5c040ffd7813b62618f757c11778bfda97a5e0.tar.xz
apk-tools-8e5c040ffd7813b62618f757c11778bfda97a5e0.zip
db: merge identical repositories
Just in case same repository is mentioned with different tags.
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/database.c b/src/database.c
index 19dc837..0f79393 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1896,10 +1896,7 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t _repository)
struct apk_repository *repo;
apk_blob_t brepo, btag;
int repo_num, r, targz = 1, tag_id = 0;
- char buf[PATH_MAX];
-
- if (db->num_repos >= APK_MAX_REPOS)
- return -1;
+ char buf[PATH_MAX], *url;
brepo = _repository;
btag = APK_BLOB_NULL;
@@ -1913,10 +1910,25 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t _repository)
tag_id = apk_db_get_tag_id(db, btag);
}
+ url = apk_blob_cstr(brepo);
+ for (repo_num = 0; repo_num < db->num_repos; repo_num++) {
+ repo = &db->repos[repo_num];
+ if (strcmp(url, repo->url) == 0) {
+ db->repo_tags[tag_id].allowed_repos |=
+ BIT(repo_num) & ~db->bad_repos;
+ free(url);
+ return 0;
+ }
+ }
+ if (db->num_repos >= APK_MAX_REPOS) {
+ free(url);
+ return -1;
+ }
+
repo_num = db->num_repos++;
repo = &db->repos[repo_num];
*repo = (struct apk_repository) {
- .url = apk_blob_cstr(brepo),
+ .url = url,
};
if (apk_url_local_file(repo->url) == NULL) {