Commit f5dfa021 by willmcgugan

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

parent 13406444
......@@ -668,7 +668,8 @@ class FS(object):
copyfile = self.copy
copyfile = self.copy
self.makedir(dst, allow_recreate=overwrite)
if dst:
self.makedir(dst, allow_recreate=overwrite)
for dirname, filenames in self.walk(src):
dst_dirname = relpath(dirname[len(src):])
......
......@@ -226,8 +226,8 @@ class MemoryFS(FS):
@synchronize
def makedir(self, dirname, recursive=False, allow_recreate=False):
if not dirname:
raise PathError("", "Path is empty")
if not dirname:
raise PathError(dirname)
fullpath = dirname
dirpath, dirname = pathsplit(dirname)
......
......@@ -126,6 +126,8 @@ class MountFS(FS):
fs, mount_path, delegate_path = self._delegate(path)
if fs is self:
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)
@synchronize
......
......@@ -202,3 +202,7 @@ def isprefix(path1,path2):
return False
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
if __name__ == "__main__":
from fs.osfs import *
fs = OSFS('~/duptest')
for files in find_duplicates(fs, quick=False):
print files
from osfs import *
fs = OSFS('~/copytest')
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