Commit f5dfa021 by willmcgugan

Fixed issue with using copydir to copy to the root of a memoryfs

parent 13406444
...@@ -668,6 +668,7 @@ class FS(object): ...@@ -668,6 +668,7 @@ class FS(object):
copyfile = self.copy copyfile = self.copy
copyfile = self.copy copyfile = self.copy
if dst:
self.makedir(dst, allow_recreate=overwrite) self.makedir(dst, allow_recreate=overwrite)
for dirname, filenames in self.walk(src): for dirname, filenames in self.walk(src):
......
...@@ -227,7 +227,7 @@ class MemoryFS(FS): ...@@ -227,7 +227,7 @@ class MemoryFS(FS):
@synchronize @synchronize
def makedir(self, dirname, recursive=False, allow_recreate=False): def makedir(self, dirname, recursive=False, allow_recreate=False):
if not dirname: if not dirname:
raise PathError("", "Path is empty") raise PathError(dirname)
fullpath = dirname fullpath = dirname
dirpath, dirname = pathsplit(dirname) dirpath, dirname = pathsplit(dirname)
......
...@@ -126,6 +126,8 @@ class MountFS(FS): ...@@ -126,6 +126,8 @@ class MountFS(FS):
fs, mount_path, delegate_path = self._delegate(path) fs, mount_path, delegate_path = self._delegate(path)
if fs is self: if fs is self:
raise UnsupportedError("make directory", msg="Can only makedir for mounted paths" ) raise UnsupportedError("make directory", msg="Can only makedir for mounted paths" )
if not delegate_path:
return True
return fs.makedir(delegate_path, recursive=recursive, allow_recreate=allow_recreate) return fs.makedir(delegate_path, recursive=recursive, allow_recreate=allow_recreate)
@synchronize @synchronize
......
...@@ -202,3 +202,7 @@ def isprefix(path1,path2): ...@@ -202,3 +202,7 @@ def isprefix(path1,path2):
return False return False
return True return True
def forcedir(path):
if not path.endswith('/'):
return path + '/'
return path
...@@ -245,7 +245,15 @@ def find_duplicates(fs, compare_paths=None, quick=False, signature_chunk_size=16 ...@@ -245,7 +245,15 @@ def find_duplicates(fs, compare_paths=None, quick=False, signature_chunk_size=16
if __name__ == "__main__": if __name__ == "__main__":
from fs.osfs import * from osfs import *
fs = OSFS('~/duptest') fs = OSFS('~/copytest')
for files in find_duplicates(fs, quick=False):
print files from memoryfs import *
m = MemoryFS()
m.makedir('maps')
copydir((fs, 'maps'), (m, 'maps'))
from browsewin import browse
browse(m)
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