Commit 14ca0ee8 by rfkelly0

better copying behaviour in remote.CacheFS

parent 7de29d32
...@@ -117,10 +117,10 @@ def cached(func): ...@@ -117,10 +117,10 @@ def cached(func):
raise raise
else: else:
self._cache_set(path,func.__name__,args,kwds,(True,res)) self._cache_set(path,func.__name__,args,kwds,(True,res))
return res return copy.copy(res)
else: else:
if not success: if not success:
raise copy.copy(result) raise result
else: else:
return copy.copy(result) return copy.copy(result)
return wrapper return wrapper
...@@ -180,26 +180,9 @@ class CacheFS(WrapFS): ...@@ -180,26 +180,9 @@ class CacheFS(WrapFS):
if cache is None: if cache is None:
return return
# Adjust cached 'listdir' for parent directory. # Adjust cached 'listdir' for parent directory.
# Currently we only do this for argment-less listdir() calls. # TODO: account for whether it was added, removed, or unmoved
# There's probably a better way to manage this...
cache[""].pop("getinfo",None) cache[""].pop("getinfo",None)
cache[""].pop("getsize",None) cache[""].pop("getsize",None)
if added:
for (key,val) in list(cache[""].get("listdir",{}).items()):
if key == ((),()):
val[1][1].append(basename(path))
else:
cache[""].pop(key,None)
elif removed:
for (key,val) in list(cache[""].get("listdir",{}).items()):
if key == ((),()):
try:
val[1][1].remove(basename(path))
except ValueError:
pass
else:
cache[""].pop(key,None)
elif not unmoved:
cache[""].pop("listdir",None) cache[""].pop("listdir",None)
# Clear all cached info for the path itself. # Clear all cached info for the path itself.
cache[names[-1]] = {"":{}} cache[names[-1]] = {"":{}}
......
...@@ -17,7 +17,7 @@ from fs import s3fs ...@@ -17,7 +17,7 @@ from fs import s3fs
class TestS3FS(unittest.TestCase,FSTestCases,ThreadingTestCases): class TestS3FS(unittest.TestCase,FSTestCases,ThreadingTestCases):
# Disable the tests by default # Disable the tests by default
#__test__ = False __test__ = False
bucket = "test-s3fs.rfk.id.au" bucket = "test-s3fs.rfk.id.au"
......
...@@ -143,6 +143,7 @@ class WrapFS(FS): ...@@ -143,6 +143,7 @@ class WrapFS(FS):
entries = [] entries = []
for e in self.wrapped_fs.listdir(self._encode(path),**kwds): for e in self.wrapped_fs.listdir(self._encode(path),**kwds):
if info: if info:
e = e.copy()
e["name"] = self._decode(e["name"]) e["name"] = self._decode(e["name"])
if wildcard is not None and not fnmatch(e["name"],wildcard): if wildcard is not None and not fnmatch(e["name"],wildcard):
continue continue
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment