use the xdg cache directory for the job cache
this places the cache file in $XDG_CACHE_HOME/jenkins_jobs/ instead of $HOME/ the xdg cache home is defined as ~/.cache/ if $XDG_CACHE_HOME is unset Existing files are not moved automatically. Change-Id: I0937346b08ba8d199422aea4043ebad087d92cca Reviewed-on: https://review.openstack.org/16665 Reviewed-by: Clark Boylan <clark.boylan@gmail.com> Reviewed-by: James E. Blair <corvus@inaugust.com> Approved: James E. Blair <corvus@inaugust.com> Tested-by: Jenkins
This commit is contained in:
parent
7bcc38c3c6
commit
e23d23906b
@ -246,7 +246,8 @@ class XmlJob(object):
|
||||
|
||||
class CacheStorage(object):
|
||||
def __init__(self):
|
||||
self.cachefilename = os.path.expanduser('~/.jenkins_jobs_cache.yml')
|
||||
cache_dir = self.get_cache_dir()
|
||||
self.cachefilename = os.path.join(cache_dir, 'jenkins_jobs_cache.yml')
|
||||
try:
|
||||
yfile = file(self.cachefilename, 'r')
|
||||
except IOError:
|
||||
@ -255,6 +256,18 @@ class CacheStorage(object):
|
||||
self.data = yaml.load(yfile)
|
||||
yfile.close()
|
||||
|
||||
@staticmethod
|
||||
def get_cache_dir():
|
||||
home = os.path.expanduser('~')
|
||||
if home == '~':
|
||||
raise OSError('Could not locate home folder')
|
||||
xdg_cache_home = os.environ.get('XDG_CACHE_HOME') or \
|
||||
os.path.join(home, '.cache')
|
||||
path = os.path.join(xdg_cache_home, 'jenkins_jobs')
|
||||
if not os.path.isdir(path):
|
||||
os.makedirs(path)
|
||||
return path
|
||||
|
||||
def set(self, job, md5):
|
||||
self.data[job] = md5
|
||||
yfile = file(self.cachefilename, 'w')
|
||||
|
Loading…
x
Reference in New Issue
Block a user