summaryrefslogtreecommitdiff
path: root/morphlib/localartifactcache.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-07-15 12:23:49 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-07-15 12:23:49 +0000
commite8adedb8f3f27d9212caf277b8e8f7c6792a20c2 (patch)
treef8460c9ff73cea780d944f18d1bab49f2653b1cf /morphlib/localartifactcache.py
parent3f686a074fdb66e75e67e276d21bdc604b34920c (diff)
parent40a5c752de62dd1b3ef3ec0850f1f24e7af67052 (diff)
downloadmorph-e8adedb8f3f27d9212caf277b8e8f7c6792a20c2.tar.gz
Fix JSON file handling to be binary filename safe
Reviewed-by: Lars Wirzenius Reviewed-by: Pedro Alvarez
Diffstat (limited to 'morphlib/localartifactcache.py')
-rw-r--r--morphlib/localartifactcache.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/morphlib/localartifactcache.py b/morphlib/localartifactcache.py
index 4c7f7832..955ee97f 100644
--- a/morphlib/localartifactcache.py
+++ b/morphlib/localartifactcache.py
@@ -96,14 +96,23 @@ class LocalArtifactCache(object):
os.utime(filename, None)
return open(filename)
+ def _join(self, basename):
+ '''Wrapper for pyfilesystem's getsyspath.
+
+ This is required because its API throws us a garbage unicode
+ string, when file paths are binary data.
+ '''
+ return str(self.cachefs.getsyspath(basename))
+
def artifact_filename(self, artifact):
- return self.cachefs.getsyspath(artifact.basename())
+ basename = artifact.basename()
+ return self._join(basename)
def _artifact_metadata_filename(self, artifact, name):
- return self.cachefs.getsyspath(artifact.metadata_basename(name))
+ return self._join(artifact.metadata_basename(name))
def _source_metadata_filename(self, source, cachekey, name):
- return self.cachefs.getsyspath('%s.%s' % (cachekey, name))
+ return self._join('%s.%s' % (cachekey, name))
def clear(self):
'''Clear everything from the artifact cache directory.