summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libalpm/be_sync.c4
-rw-r--r--lib/libalpm/dload.c20
-rw-r--r--lib/libalpm/dload.h2
-rw-r--r--lib/libalpm/sync.c2
4 files changed, 16 insertions, 12 deletions
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index a5a2c10d..66e351b5 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -218,7 +218,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
payload.force = force;
payload.unlink_on_fail = 1;
- ret = _alpm_download(&payload, syncpath, NULL);
+ ret = _alpm_download(&payload, syncpath, NULL, NULL);
_alpm_dload_payload_reset(&payload);
if(ret == 0 && (level & ALPM_SIG_DATABASE)) {
@@ -244,7 +244,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
/* set hard upper limit of 16KiB */
payload.max_size = 16 * 1024;
- sig_ret = _alpm_download(&payload, syncpath, NULL);
+ sig_ret = _alpm_download(&payload, syncpath, NULL, NULL);
/* errors_ok suppresses error messages, but not the return code */
sig_ret = payload.errors_ok ? 0 : sig_ret;
_alpm_dload_payload_reset(&payload);
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index 19f629d1..280eaaf1 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -386,7 +386,7 @@ static FILE *create_tempfile(struct dload_payload *payload, const char *localpat
#define HOSTNAME_SIZE 256
static int curl_download_internal(struct dload_payload *payload,
- const char *localpath, char **final_file)
+ const char *localpath, char **final_file, char **final_url)
{
int ret = -1;
FILE *localf = NULL;
@@ -523,6 +523,10 @@ static int curl_download_internal(struct dload_payload *payload,
curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &timecond);
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &effective_url);
+ if(final_url != NULL) {
+ *final_url = effective_url;
+ }
+
/* time condition was met and we didn't download anything. we need to
* clean up the 0 byte .part file that's left behind. */
if(timecond == 1 && DOUBLE_EQ(bytes_dl, 0)) {
@@ -613,13 +617,13 @@ cleanup:
* @return 0 on success, -1 on error (pm_errno is set accordingly if errors_ok == 0)
*/
int _alpm_download(struct dload_payload *payload, const char *localpath,
- char **final_file)
+ char **final_file, char **final_url)
{
alpm_handle_t *handle = payload->handle;
if(handle->fetchcb == NULL) {
#ifdef HAVE_LIBCURL
- return curl_download_internal(payload, localpath, final_file);
+ return curl_download_internal(payload, localpath, final_file, final_url);
#else
RET_ERR(handle, ALPM_ERR_EXTERNAL_DOWNLOAD, -1);
#endif
@@ -653,7 +657,7 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url)
{
char *filepath;
const char *cachedir;
- char *final_file = NULL;
+ char *final_file = NULL, *final_pkg_url = NULL;
struct dload_payload payload;
int ret = 0;
@@ -673,7 +677,7 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url)
payload.handle = handle;
/* download the file */
- ret = _alpm_download(&payload, cachedir, &final_file);
+ ret = _alpm_download(&payload, cachedir, &final_file, &final_pkg_url);
_alpm_dload_payload_reset(&payload);
if(ret == -1) {
_alpm_log(handle, ALPM_LOG_WARNING, _("failed to download %s\n"), url);
@@ -688,9 +692,9 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url)
char *sig_filepath, *sig_final_file = NULL;
size_t len;
- len = strlen(url) + 5;
+ len = strlen(final_pkg_url) + 5;
MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
- snprintf(payload.fileurl, len, "%s.sig", url);
+ snprintf(payload.fileurl, len, "%s.sig", final_pkg_url);
sig_filepath = filecache_find_url(handle, payload.fileurl);
if(sig_filepath == NULL) {
@@ -701,7 +705,7 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url)
/* set hard upper limit of 16KiB */
payload.max_size = 16 * 1024;
- ret = _alpm_download(&payload, cachedir, &sig_final_file);
+ ret = _alpm_download(&payload, cachedir, &sig_final_file, NULL);
if(ret == -1 && !payload.errors_ok) {
_alpm_log(handle, ALPM_LOG_WARNING,
_("failed to download %s\n"), payload.fileurl);
diff --git a/lib/libalpm/dload.h b/lib/libalpm/dload.h
index 70e34791..95bb91a3 100644
--- a/lib/libalpm/dload.h
+++ b/lib/libalpm/dload.h
@@ -48,7 +48,7 @@ struct dload_payload {
void _alpm_dload_payload_reset(struct dload_payload *payload);
int _alpm_download(struct dload_payload *payload, const char *localpath,
- char **final_file);
+ char **final_file, char **final_url);
#endif /* _ALPM_DLOAD_H */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index efd5c3f0..6a5cab63 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -877,7 +877,7 @@ static int download_single_file(alpm_handle_t *handle, struct dload_payload *pay
MALLOC(payload->fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
snprintf(payload->fileurl, len, "%s/%s", server_url, payload->remote_name);
- if(_alpm_download(payload, cachedir, NULL) != -1) {
+ if(_alpm_download(payload, cachedir, NULL, NULL) != -1) {
return 0;
}