1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-12 04:15:06 -05:00

Don't stat cachedir immediately

By attempting to stat the cachedir when we load the pacman config, pacman
bails out if it is a non-existant directory, even if it will never be
needed. This is unfortunate as it is only used for sync transactions anyway.
Instead, wait until we need it in _alpm_filecache_setup to actually do
anything.

Reported as FS#9096.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2008-01-05 17:39:38 -06:00
parent 5aa873edb6
commit 1a0aaa20df
2 changed files with 3 additions and 8 deletions

View File

@ -362,7 +362,6 @@ int SYMEXPORT alpm_option_set_dbpath(const char *dbpath)
int SYMEXPORT alpm_option_add_cachedir(const char *cachedir) int SYMEXPORT alpm_option_add_cachedir(const char *cachedir)
{ {
struct stat st;
char *newcachedir; char *newcachedir;
size_t cachedirlen; size_t cachedirlen;
@ -372,10 +371,9 @@ int SYMEXPORT alpm_option_add_cachedir(const char *cachedir)
pm_errno = PM_ERR_WRONG_ARGS; pm_errno = PM_ERR_WRONG_ARGS;
return(-1); return(-1);
} }
if(stat(cachedir, &st) == -1 || !S_ISDIR(st.st_mode)) { /* don't stat the cachedir yet, as it may not even be needed. we can
pm_errno = PM_ERR_NOT_A_DIR; * fail later if it is needed and the path is invalid. */
return(-1);
}
/* verify cachedir ends in a '/' */ /* verify cachedir ends in a '/' */
cachedirlen = strlen(cachedir); cachedirlen = strlen(cachedir);
if(cachedir[cachedirlen-1] != '/') { if(cachedir[cachedirlen-1] != '/') {

View File

@ -571,8 +571,6 @@ const char *_alpm_filecache_setup(void)
/* cache directory does not exist.... try creating it */ /* cache directory does not exist.... try creating it */
_alpm_log(PM_LOG_WARNING, _("no %s cache exists, creating...\n"), _alpm_log(PM_LOG_WARNING, _("no %s cache exists, creating...\n"),
cachedir); cachedir);
alpm_logaction("warning: no %s cache exists, creating...\n",
cachedir);
if(_alpm_makepath(cachedir) == 0) { if(_alpm_makepath(cachedir) == 0) {
_alpm_log(PM_LOG_DEBUG, "using cachedir: %s\n", cachedir); _alpm_log(PM_LOG_DEBUG, "using cachedir: %s\n", cachedir);
return(cachedir); return(cachedir);
@ -590,7 +588,6 @@ const char *_alpm_filecache_setup(void)
alpm_option_set_cachedirs(tmp); alpm_option_set_cachedirs(tmp);
_alpm_log(PM_LOG_DEBUG, "using cachedir: %s", "/tmp/\n"); _alpm_log(PM_LOG_DEBUG, "using cachedir: %s", "/tmp/\n");
_alpm_log(PM_LOG_WARNING, _("couldn't create package cache, using /tmp instead\n")); _alpm_log(PM_LOG_WARNING, _("couldn't create package cache, using /tmp instead\n"));
alpm_logaction("warning: couldn't create package cache, using /tmp instead\n");
return(alpm_list_getdata(tmp)); return(alpm_list_getdata(tmp));
} }