Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/be_sync.c
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2015-07-14 21:45:59 +1000
committerAllan McRae <allan@archlinux.org>2015-07-15 10:57:29 +1000
commitf6c55b3c3f395839c0973c36b7a7e05984636a61 (patch)
tree16d85d4e4fca3bb8249a58f4b93f9088d6f5df55 /lib/libalpm/be_sync.c
parent1ada16f0177f9bfcaed95cf3b71b7029290a5f1d (diff)
Allow frontends to specify the sync database extension
This allows frontends to select between the .db and .files databases currently supplied by repo-add or any other compatible database. Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/be_sync.c')
-rw-r--r--lib/libalpm/be_sync.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index ea979e6d..a4ba0f79 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -174,6 +174,7 @@ valid:
int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
{
char *syncpath;
+ const char *dbext;
alpm_list_t *i;
int ret = -1;
mode_t oldmask;
@@ -208,6 +209,8 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
RET_ERR(handle, ALPM_ERR_HANDLE_LOCK, -1);
}
+ dbext = db->handle->dbext;
+
for(i = db->servers; i; i = i->next) {
const char *server = i->data, *final_db_url = NULL;
struct dload_payload payload;
@@ -220,10 +223,10 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
payload.max_size = 25 * 1024 * 1024;
/* print server + filename into a buffer */
- len = strlen(server) + strlen(db->treename) + 5;
+ len = strlen(server) + strlen(db->treename) + strlen(dbext) + 2;
/* TODO fix leak syncpath and umask unset */
MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
- snprintf(payload.fileurl, len, "%s/%s.db", server, db->treename);
+ snprintf(payload.fileurl, len, "%s/%s%s", server, db->treename, dbext);
payload.handle = handle;
payload.force = force;
payload.unlink_on_fail = 1;
@@ -244,7 +247,9 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
/* check if the final URL from internal downloader looks reasonable */
if(final_db_url != NULL) {
- if(strlen(final_db_url) < 3 || strcmp(final_db_url + strlen(final_db_url) - 3, ".db") != 0) {
+ if(strlen(final_db_url) < 3
+ || strcmp(final_db_url + strlen(final_db_url) - strlen(dbext),
+ dbext) != 0) {
final_db_url = NULL;
}
}
@@ -254,8 +259,8 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
/* print final_db_url into a buffer (leave space for .sig) */
len = strlen(final_db_url) + 5;
} else {
- /* print server + filename into a buffer (leave space for separator and .db.sig) */
- len = strlen(server) + strlen(db->treename) + 9;
+ /* print server + filename into a buffer (leave space for separator and .sig) */
+ len = strlen(server) + strlen(db->treename) + strlen(dbext) + 6;
}
/* TODO fix leak syncpath and umask unset */
@@ -264,7 +269,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
if(final_db_url != NULL) {
snprintf(payload.fileurl, len, "%s.sig", final_db_url);
} else {
- snprintf(payload.fileurl, len, "%s/%s.db.sig", server, db->treename);
+ snprintf(payload.fileurl, len, "%s/%s%s.sig", server, db->treename, dbext);
}
payload.handle = handle;