summaryrefslogtreecommitdiff
path: root/lib/libalpm/handle.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-06-04 14:50:16 -0400
committerDan McGee <dan@archlinux.org>2007-06-09 13:03:25 -0400
commit35a794c2ed4da7da44d3a04794fc90615e7c52e7 (patch)
tree75fd2667a69867795f6a32cc9bb1dc7d505e2004 /lib/libalpm/handle.c
parentb6f3fe6957d0206485eac98fb2120578b75d0058 (diff)
downloadpacman-35a794c2ed4da7da44d3a04794fc90615e7c52e7.tar.xz
Allow multiple CacheDirs to be specified
This should hopefully allow multiple cache dirs to be specified in pacman.conf and/or on the command line, and allow pacman to test each one for the package file. The first one found to be writeable is used as the download cache. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/handle.c')
-rw-r--r--lib/libalpm/handle.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index ae20ef11..6f9e3330 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -80,7 +80,7 @@ pmhandle_t *_alpm_handle_new()
#endif
handle->root = NULL;
handle->dbpath = NULL;
- handle->cachedir = NULL;
+ handle->cachedirs = NULL;
handle->lockfile = NULL;
handle->logfile = NULL;
@@ -109,7 +109,7 @@ void _alpm_handle_free(pmhandle_t *handle)
_alpm_trans_free(handle->trans);
FREE(handle->root);
FREE(handle->dbpath);
- FREE(handle->cachedir);
+ FREELIST(handle->cachedirs);
FREE(handle->logfile);
FREE(handle->lockfile);
FREE(handle->xfercommand);
@@ -125,7 +125,7 @@ alpm_cb_log SYMEXPORT alpm_option_get_logcb() { return (handle ? handle->logcb :
alpm_cb_download SYMEXPORT alpm_option_get_dlcb() { return (handle ? handle->dlcb : NULL); }
const char SYMEXPORT *alpm_option_get_root() { return handle->root; }
const char SYMEXPORT *alpm_option_get_dbpath() { return handle->dbpath; }
-const char SYMEXPORT *alpm_option_get_cachedir() { return handle->cachedir; }
+alpm_list_t SYMEXPORT *alpm_option_get_cachedirs() { return handle->cachedirs; }
const char SYMEXPORT *alpm_option_get_logfile() { return handle->logfile; }
const char SYMEXPORT *alpm_option_get_lockfile() { return handle->lockfile; }
unsigned short SYMEXPORT alpm_option_get_usesyslog() { return handle->usesyslog; }
@@ -193,23 +193,31 @@ void SYMEXPORT alpm_option_set_dbpath(const char *dbpath)
}
}
-void SYMEXPORT alpm_option_set_cachedir(const char *cachedir)
+void SYMEXPORT alpm_option_add_cachedir(const char *cachedir)
{
ALPM_LOG_FUNC;
- if(handle->cachedir) FREE(handle->cachedir);
if(cachedir) {
+ char *newcachedir;
/* verify cachedir ends in a '/' */
int cachedirlen = strlen(cachedir);
if(cachedir[cachedirlen-1] != '/') {
cachedirlen += 1;
}
- handle->cachedir = calloc(cachedirlen+1, sizeof(char));
- strncpy(handle->cachedir, cachedir, cachedirlen);
- handle->cachedir[cachedirlen-1] = '/';
+ newcachedir = calloc(cachedirlen + 1, sizeof(char));
+ strncpy(newcachedir, cachedir, cachedirlen);
+ newcachedir[cachedirlen-1] = '/';
+ handle->cachedirs = alpm_list_add(handle->cachedirs, newcachedir);
+ _alpm_log(PM_LOG_DEBUG, _("option 'cachedir' = %s"), newcachedir);
}
}
+void SYMEXPORT alpm_option_set_cachedirs(alpm_list_t *cachedirs)
+{
+ if(handle->cachedirs) FREELIST(handle->cachedirs);
+ if(cachedirs) handle->cachedirs = cachedirs;
+}
+
void SYMEXPORT alpm_option_set_logfile(const char *logfile)
{
ALPM_LOG_FUNC;