Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs.utils.copydir: RuntimeError: maximum recursion depth exceeded in cmp #251

Open
zopyx opened this issue Apr 23, 2016 · 3 comments
Open

Comments

@zopyx
Copy link

zopyx commented Apr 23, 2016

The following script gives me the attached error

from fs.contrib.davfs import DAVFS
from fs.osfs import OSFS
import fs.utils

source = OSFS('/tmp/bookalope')
target = DAVFS('http://localhost:6080/exist/webdav/db', credentials=dict(username='admin', password='onkopedia'))


print source.listdir()
print target.listdir()

fs.utils.copydir((source, 'zopyx-nimbudocs'), (target, '.'))

  File "/home/ajung/.buildout/eggs/fs-0.5.4-py2.7.egg/fs/contrib/davfs/__init__.py", line 556, in makedir
    self.makedir(dirname(path),recursive=True,allow_recreate=True)
  File "/home/ajung/.buildout/eggs/fs-0.5.4-py2.7.egg/fs/contrib/davfs/__init__.py", line 556, in makedir
    self.makedir(dirname(path),recursive=True,allow_recreate=True)
  File "/home/ajung/.buildout/eggs/fs-0.5.4-py2.7.egg/fs/contrib/davfs/__init__.py", line 556, in makedir
    self.makedir(dirname(path),recursive=True,allow_recreate=True)
  File "/home/ajung/.buildout/eggs/fs-0.5.4-py2.7.egg/fs/contrib/davfs/__init__.py", line 556, in makedir
    self.makedir(dirname(path),recursive=True,allow_recreate=True)
  File "/home/ajung/.buildout/eggs/fs-0.5.4-py2.7.egg/fs/contrib/davfs/__init__.py", line 556, in makedir
    self.makedir(dirname(path),recursive=True,allow_recreate=True)
  File "/home/ajung/.buildout/eggs/fs-0.5.4-py2.7.egg/fs/contrib/davfs/__init__.py", line 556, in makedir
    self.makedir(dirname(path),recursive=True,allow_recreate=True)
  File "/home/ajung/.buildout/eggs/fs-0.5.4-py2.7.egg/fs/contrib/davfs/__init__.py", line 556, in makedir
    self.makedir(dirname(path),recursive=True,allow_recreate=True)
  File "/home/ajung/.buildout/eggs/fs-0.5.4-py2.7.egg/fs/contrib/davfs/__init__.py", line 556, in makedir
    self.makedir(dirname(path),recursive=True,allow_recreate=True)
  File "/home/ajung/.buildout/eggs/fs-0.5.4-py2.7.egg/fs/contrib/davfs/__init__.py", line 556, in makedir
    self.makedir(dirname(path),recursive=True,allow_recreate=True)
  File "/home/ajung/.buildout/eggs/fs-0.5.4-py2.7.egg/fs/contrib/davfs/__init__.py", line 556, in makedir
    self.makedir(dirname(path),recursive=True,allow_recreate=True)
  File "/home/ajung/.buildout/eggs/fs-0.5.4-py2.7.egg/fs/contrib/davfs/__init__.py", line 549, in makedir
    response = self._request(path,"MKCOL")
  File "/home/ajung/.buildout/eggs/fs-0.5.4-py2.7.egg/fs/contrib/davfs/__init__.py", line 260, in _request
    resp = self._raw_request(url,method,body,headers)
  File "/home/ajung/.buildout/eggs/fs-0.5.4-py2.7.egg/fs/contrib/davfs/__init__.py", line 321, in _raw_request
    resp = con.getresponse()
  File "/opt/buildout.python/parts/opt/lib/python2.7/httplib.py", line 1136, in getresponse
    response.begin()
  File "/opt/buildout.python/parts/opt/lib/python2.7/httplib.py", line 485, in begin
    self.msg = HTTPMessage(self.fp, 0)
  File "/opt/buildout.python/parts/opt/lib/python2.7/mimetools.py", line 25, in __init__
    rfc822.Message.__init__(self, fp, seekable)
  File "/opt/buildout.python/parts/opt/lib/python2.7/rfc822.py", line 108, in __init__
    self.readheaders()
  File "/opt/buildout.python/parts/opt/lib/python2.7/httplib.py", line 340, in readheaders
    elif self.islast(line):
  File "/opt/buildout.python/parts/opt/lib/python2.7/rfc822.py", line 222, in islast
    return line in _blanklines
RuntimeError: maximum recursion depth exceeded in cmp
@lurch
Copy link
Contributor

lurch commented Apr 26, 2016

If you're exceeding the recursion depth, then my initial guess would be that your filesystem is too deeply nested?

Can you upload the output of the following script somewhere?

from fs.osfs import OSFS
source = OSFS('/tmp/bookalope')
source.tree(max_levels=None)

EDIT: Added the max_levels parameter, otherwise tree stops at 5 levels deep

@zopyx
Copy link
Author

zopyx commented Apr 27, 2016

The really nested. The folder just contains a dozen folders.

@lurch
Copy link
Contributor

lurch commented Apr 27, 2016

I've been having a play around today, and eventually managed to reproduce this; and you're right it isn't a nesting problem ;-)

I'm not sure exactly where the fault lies (I've never done any WebDAV stuff before, so it could be with either the fs.contrib.davfs code, or it could be with the eXist-db WebDAV implementation).
But if you try to do target.makedir('.') then you get the error fs.errors.ParentDirectoryMissingError: Parent directory is missing: .. This means the code inside https://github.com/PyFilesystem/pyfilesystem/blob/master/fs/contrib/davfs/__init__.py#L548 then tries to do target.makedir('') which also gives a ParentDirectoryMissingError, and so the code gets stuck in an inifinite loop, until it reaches the recursion limit.

So a simple workaround for your test-code above would be to change it to:

fs.utils.copydir((source, 'zopyx-nimbudocs'), target)

which seems to bypass the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants