[yum-commits] Branch 'yum-3_2_X' - yum/misc.py
skvidal at osuosl.org
skvidal at osuosl.org
Mon Feb 23 19:39:38 UTC 2009
yum/misc.py | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
New commits:
commit 56b7b08f3f344a9e77335e7870b35b56349857cc
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Mon Feb 23 14:38:29 2009 -0500
add option to getCacheDir() to allow you to turn off the cachedir reuse feature
diff --git a/yum/misc.py b/yum/misc.py
index ead141d..c7ee7b6 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -499,7 +499,7 @@ def valid_detached_sig(sig_file, signed_file, gpghome=None):
return False
-def getCacheDir(tmpdir='/var/tmp'):
+def getCacheDir(tmpdir='/var/tmp', reuse=True):
"""return a path to a valid and safe cachedir - only used when not running
as root or when --tempcache is set"""
@@ -510,15 +510,16 @@ def getCacheDir(tmpdir='/var/tmp'):
except KeyError:
return None # if it returns None then, well, it's bollocksed
- # check for /var/tmp/yum-username-* -
prefix = 'yum-%s-' % username
- dirpath = '%s/%s*' % (tmpdir, prefix)
- cachedirs = sorted(glob.glob(dirpath))
- for thisdir in cachedirs:
- stats = os.lstat(thisdir)
- if S_ISDIR(stats[0]) and S_IMODE(stats[0]) == 448 and stats[4] == uid:
- return thisdir
+ if reuse:
+ # check for /var/tmp/yum-username-* -
+ dirpath = '%s/%s*' % (tmpdir, prefix)
+ cachedirs = sorted(glob.glob(dirpath))
+ for thisdir in cachedirs:
+ stats = os.lstat(thisdir)
+ if S_ISDIR(stats[0]) and S_IMODE(stats[0]) == 448 and stats[4] == uid:
+ return thisdir
# make the dir (tempfile.mkdtemp())
cachedir = tempfile.mkdtemp(prefix=prefix, dir=tmpdir)
More information about the Yum-commits
mailing list