|
|
|
|
@ -489,17 +489,8 @@ class FileContentsManager(FileManagerMixin, ContentsManager):
|
|
|
|
|
path = path.strip('/')
|
|
|
|
|
os_path = self._get_os_path(path)
|
|
|
|
|
rm = os.unlink
|
|
|
|
|
if os.path.isdir(os_path):
|
|
|
|
|
listing = os.listdir(os_path)
|
|
|
|
|
# Don't delete non-empty directories.
|
|
|
|
|
# A directory containing only leftover checkpoints is
|
|
|
|
|
# considered empty.
|
|
|
|
|
cp_dir = getattr(self.checkpoints, 'checkpoint_dir', None)
|
|
|
|
|
for entry in listing:
|
|
|
|
|
if entry != cp_dir:
|
|
|
|
|
raise web.HTTPError(400, u'Directory %s not empty' % os_path)
|
|
|
|
|
elif not os.path.isfile(os_path):
|
|
|
|
|
raise web.HTTPError(404, u'File does not exist: %s' % os_path)
|
|
|
|
|
if not os.path.exists(os_path):
|
|
|
|
|
raise web.HTTPError(404, u'File or directory does not exist: %s' % os_path)
|
|
|
|
|
|
|
|
|
|
if self.delete_to_trash:
|
|
|
|
|
self.log.debug("Sending %s to trash", os_path)
|
|
|
|
|
|