whole-tale / wt_home_dirs

0 stars 1 forks source link

Copying items between workspaces fails if workspace wasn't mounted at least once #21

Closed Xarthisius closed 5 years ago

Xarthisius commented 5 years ago

AFAICT directory initializer is not called until a workspace is mounted for the first time. As a result, a folder in /collection/WholeTale Workspaces/WholeTale workspaces can be created via Girder API without a corresponding physical root. If an item is copied to such workspace it yields:

Traceback (most recent call last):
  File "/girder/girder/api/rest.py", line 630, in endpointDecorator
    val = fun(self, path, params)
  File "/girder/girder/api/rest.py", line 1224, in POST
    return self.handleRoute(method, path, params)
  File "/girder/girder/api/rest.py", line 967, in handleRoute
    val = handler(**kwargs)
  File "/girder/girder/api/access.py", line 63, in wrapped
    return fun(*args, **kwargs)
  File "/girder/girder/api/describe.py", line 709, in wrapped
    return fun(*args, **kwargs)
  File "/girder/girder/api/v1/resource.py", line 374, in copyResources
    model.copyItem(doc, folder=parent, creator=user)
  File "/girder/girder/models/item.py", line 445, in copyItem
    events.trigger('model.item.copy.prepare', (srcItem, newItem))
  File "/girder/girder/events.py", line 314, in trigger
    handler['handler'](e)
  File "/girder/plugins/wt_home_dir/server/__init__.py", line 80, in handler
    h.run(event, path, e.pathMapper, provider)
  File "/girder/plugins/wt_home_dir/server/lib/EventHandlers.py", line 215, in run
    FileResource.copyMoveSingle(res, davDstPath.as_posix(), False)
  File "/usr/local/lib/python3.5/dist-packages/wsgidav/fs_dav_provider.py", line 116, in copyMoveSingle
    shutil.copy2(self._filePath, fpDest)
  File "/usr/lib/python3.5/shutil.py", line 257, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.5/shutil.py", line 121, in copyfile
    with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/wt-tale-dirs/5/5c5a2b909f86860001ea7de2/file_root.txt'
Additional info:
  Request URL: POST https://girder.local.wholetale.org/api/v1/resource/copy
  Query string: 
  Remote IP: 10.255.0.2