summaryrefslogtreecommitdiff
path: root/morphlib/localrepocache.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-04-10 13:00:38 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-04-10 13:00:38 +0100
commit8a9d16e11494b0671480719ede416c0c2b555a3b (patch)
tree911c7e6b13fcfc24bcf5dc7421b3f014f63a396c /morphlib/localrepocache.py
parentb1c6d2e4069ad466e8982236f4ca8611b24040cb (diff)
downloadmorph-8a9d16e11494b0671480719ede416c0c2b555a3b.tar.gz
Create cache directory when needed in LocalRepoCache
Diffstat (limited to 'morphlib/localrepocache.py')
-rw-r--r--morphlib/localrepocache.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/morphlib/localrepocache.py b/morphlib/localrepocache.py
index 9aef13e4..a51a9ead 100644
--- a/morphlib/localrepocache.py
+++ b/morphlib/localrepocache.py
@@ -113,6 +113,15 @@ class LocalRepoCache(object):
except urllib2.URLError:
return False
+ def _mkdir(self, dirname): # pragma: no cover
+ '''Create a directory.
+
+ This method is meant to be overridden by unit tests.
+
+ '''
+
+ os.mkdir(dirname)
+
def _remove(self, filename): # pragma: no cover
'''Remove given file.
@@ -171,6 +180,9 @@ class LocalRepoCache(object):
'''
+ if not self._exists(self._cachedir):
+ self._mkdir(self._cachedir)
+
for repourl, path in self._base_iterate(reponame):
if self._exists(path):
break