Make libfetch the 'native' download library
Use libfetch naming in the code in place of libdownload names. This is in preparation for dropping support for libdownload at some point as libfetch can run on Linux. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
314b4462d2
commit
8d4e1e6754
|
@ -526,7 +526,7 @@ enum _pmerrno_t {
|
||||||
PM_ERR_INVALID_REGEX,
|
PM_ERR_INVALID_REGEX,
|
||||||
/* External library errors */
|
/* External library errors */
|
||||||
PM_ERR_LIBARCHIVE,
|
PM_ERR_LIBARCHIVE,
|
||||||
PM_ERR_LIBDOWNLOAD,
|
PM_ERR_LIBFETCH,
|
||||||
PM_ERR_EXTERNAL_DOWNLOAD
|
PM_ERR_EXTERNAL_DOWNLOAD
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -35,14 +35,14 @@
|
||||||
|
|
||||||
#if defined(HAVE_LIBDOWNLOAD)
|
#if defined(HAVE_LIBDOWNLOAD)
|
||||||
#include <download.h>
|
#include <download.h>
|
||||||
|
#define fetchFreeURL downloadFreeURL
|
||||||
|
#define fetchLastErrCode downloadLastErrCode
|
||||||
|
#define fetchLastErrString downloadLastErrString
|
||||||
|
#define fetchParseURL downloadParseURL
|
||||||
|
#define fetchTimeout downloadTimeout
|
||||||
|
#define fetchXGet downloadXGet
|
||||||
#elif defined(HAVE_LIBFETCH)
|
#elif defined(HAVE_LIBFETCH)
|
||||||
#include <fetch.h>
|
#include <fetch.h>
|
||||||
#define downloadFreeURL fetchFreeURL
|
|
||||||
#define downloadLastErrCode fetchLastErrCode
|
|
||||||
#define downloadLastErrString fetchLastErrString
|
|
||||||
#define downloadParseURL fetchParseURL
|
|
||||||
#define downloadTimeout fetchTimeout
|
|
||||||
#define downloadXGet fetchXGet
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* libalpm */
|
/* libalpm */
|
||||||
|
@ -86,7 +86,7 @@ static char *get_tempfile(const char *path, const char *filename) {
|
||||||
static struct url *url_for_string(const char *url)
|
static struct url *url_for_string(const char *url)
|
||||||
{
|
{
|
||||||
struct url *ret = NULL;
|
struct url *ret = NULL;
|
||||||
ret = downloadParseURL(url);
|
ret = fetchParseURL(url);
|
||||||
if(!ret) {
|
if(!ret) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("url '%s' is invalid\n"), url);
|
_alpm_log(PM_LOG_ERROR, _("url '%s' is invalid\n"), url);
|
||||||
RET_ERR(PM_ERR_SERVER_BAD_URL, NULL);
|
RET_ERR(PM_ERR_SERVER_BAD_URL, NULL);
|
||||||
|
@ -142,23 +142,22 @@ static int download_internal(const char *url, const char *localpath,
|
||||||
dl_thisfile = 0;
|
dl_thisfile = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* libdownload does not reset the error code, reset it in
|
/* libfetch does not reset the error code */
|
||||||
* the case of previous errors */
|
fetchLastErrCode = 0;
|
||||||
downloadLastErrCode = 0;
|
|
||||||
|
|
||||||
/* 10s timeout - TODO make a config option */
|
/* 10s timeout - TODO make a config option */
|
||||||
downloadTimeout = 10000;
|
fetchTimeout = 10000;
|
||||||
|
|
||||||
dlf = downloadXGet(fileurl, &ust, (handle->nopassiveftp ? "" : "p"));
|
dlf = fetchXGet(fileurl, &ust, (handle->nopassiveftp ? "" : "p"));
|
||||||
|
|
||||||
if(downloadLastErrCode != 0 || dlf == NULL) {
|
if(fetchLastErrCode != 0 || dlf == NULL) {
|
||||||
const char *host = _("disk");
|
const char *host = _("disk");
|
||||||
if(strcmp(SCHEME_FILE, fileurl->scheme) != 0) {
|
if(strcmp(SCHEME_FILE, fileurl->scheme) != 0) {
|
||||||
host = fileurl->host;
|
host = fileurl->host;
|
||||||
}
|
}
|
||||||
pm_errno = PM_ERR_LIBDOWNLOAD;
|
pm_errno = PM_ERR_LIBFETCH;
|
||||||
_alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"),
|
_alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"),
|
||||||
filename, host, downloadLastErrString);
|
filename, host, fetchLastErrString);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
|
@ -204,9 +203,9 @@ static int download_internal(const char *url, const char *localpath,
|
||||||
char buffer[PM_DLBUF_LEN];
|
char buffer[PM_DLBUF_LEN];
|
||||||
while((nread = fread(buffer, 1, PM_DLBUF_LEN, dlf)) > 0) {
|
while((nread = fread(buffer, 1, PM_DLBUF_LEN, dlf)) > 0) {
|
||||||
if(ferror(dlf)) {
|
if(ferror(dlf)) {
|
||||||
pm_errno = PM_ERR_LIBDOWNLOAD;
|
pm_errno = PM_ERR_LIBFETCH;
|
||||||
_alpm_log(PM_LOG_ERROR, _("error downloading '%s': %s\n"),
|
_alpm_log(PM_LOG_ERROR, _("error downloading '%s': %s\n"),
|
||||||
filename, downloadLastErrString);
|
filename, fetchLastErrString);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -247,7 +246,7 @@ cleanup:
|
||||||
if(dlf != NULL) {
|
if(dlf != NULL) {
|
||||||
fclose(dlf);
|
fclose(dlf);
|
||||||
}
|
}
|
||||||
downloadFreeURL(fileurl);
|
fetchFreeURL(fileurl);
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,9 +32,9 @@
|
||||||
|
|
||||||
#if defined(HAVE_LIBDOWNLOAD)
|
#if defined(HAVE_LIBDOWNLOAD)
|
||||||
#include <download.h> /* downloadLastErrString */
|
#include <download.h> /* downloadLastErrString */
|
||||||
|
#define fetchLastErrString downloadLastErrString
|
||||||
#elif defined(HAVE_LIBFETCH)
|
#elif defined(HAVE_LIBFETCH)
|
||||||
#include <fetch.h> /* fetchLastErrString */
|
#include <fetch.h> /* fetchLastErrString */
|
||||||
#define downloadLastErrString fetchLastErrString
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* libalpm */
|
/* libalpm */
|
||||||
|
@ -154,9 +154,9 @@ const char SYMEXPORT *alpm_strerror(int err)
|
||||||
* requires the archive struct, so we can't. Just use a generic
|
* requires the archive struct, so we can't. Just use a generic
|
||||||
* error string instead. */
|
* error string instead. */
|
||||||
return _("libarchive error");
|
return _("libarchive error");
|
||||||
case PM_ERR_LIBDOWNLOAD:
|
case PM_ERR_LIBFETCH:
|
||||||
#if defined(INTERNAL_DOWNLOAD)
|
#if defined(INTERNAL_DOWNLOAD)
|
||||||
return downloadLastErrString;
|
return fetchLastErrString;
|
||||||
#else
|
#else
|
||||||
/* obviously shouldn't get here... */
|
/* obviously shouldn't get here... */
|
||||||
return _("download library error");
|
return _("download library error");
|
||||||
|
|
Loading…
Reference in New Issue