summaryrefslogtreecommitdiff
path: root/lib/libalpm/sync.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-04-21 18:31:19 -0500
committerDan McGee <dan@archlinux.org>2011-04-22 17:08:33 -0500
commit9579879b1bb1a033e846b750769215b7b4066073 (patch)
tree9d41d9c12914e72f6a900ac152c1f520d003f8d1 /lib/libalpm/sync.c
parent204bbc47149c948b680735a933fa395ce3983f38 (diff)
downloadpacman-9579879b1bb1a033e846b750769215b7b4066073.tar.xz
libalpm/dload: major refactor of signature downloading
There's a lot of related moving parts here: * Iteration through mirrors is moved back to the calling functions. This allows removal of _alpm_download_single_file and _alpm_download_files. * The download function gets a few more arguments to influence behavior. This allows several different scenarios to customize behavior: - database - database signature (req'd and optional) - package - package via direct URL - package signature via direct URL (req'd and optional) * For databases, we need signatures from the same mirror, so structure the code accordingly. Some-inspiration-from: Dave Reisner <d@falconindy.com> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/sync.c')
-rw-r--r--lib/libalpm/sync.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 63ea2b2d..4ce62e64 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -689,8 +689,8 @@ static int test_md5sum(pmtrans_t *trans, const char *filepath,
int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
{
- alpm_list_t *i, *j, *files = NULL;
- alpm_list_t *deltas = NULL;
+ alpm_list_t *i, *j, *k;
+ alpm_list_t *files = NULL, *deltas = NULL;
size_t numtargs, current = 0, replaces = 0;
int errors = 0;
const char *cachedir = NULL;
@@ -758,7 +758,26 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
if(files) {
EVENT(trans, PM_TRANS_EVT_RETRIEVE_START, current->treename, NULL);
- errors = _alpm_download_files(files, current->servers, cachedir);
+ for(j = files; j; j = j->next) {
+ const char *filename = j->data;
+ for(k = current->servers; k; k = k->next) {
+ const char *server = k->data;
+ char *fileurl;
+ size_t len;
+
+ /* print server + filename into a buffer */
+ len = strlen(server) + strlen(filename) + 2;
+ CALLOC(fileurl, len, sizeof(char), RET_ERR(PM_ERR_MEMORY, -1));
+ snprintf(fileurl, len, "%s/%s", server, filename);
+
+ ret = _alpm_download(fileurl, cachedir, 0, 1, 0);
+ FREE(fileurl);
+ if(ret != -1) {
+ break;
+ }
+ errors++;
+ }
+ }
if(errors) {
_alpm_log(PM_LOG_WARNING, _("failed to retrieve some files from %s\n"),