Esempio n. 1
0
 def removedir(self, path):
     _path = self.validatepath(path)
     if path in '/':
         raise errors.RemoveRootError()
     if not self.getinfo(path).is_dir:
         raise errors.DirectoryExpected(path)
     if not self.isempty(_path):
         raise errors.DirectoryNotEmpty(path)
     self.client.clean(_path.encode('utf-8'))
Esempio n. 2
0
 def removedir(self, path):
     self.check()
     _path = self.validatepath(path)
     if _path == "/":
         raise errors.RemoveRootError()
     info = self.getinfo(_path)
     if not info.is_dir:
         raise errors.DirectoryExpected(path)
     if not self.isempty(path):
         raise errors.DirectoryNotEmpty(path)
     _key = self._path_to_dir_key(_path)
     self.client.delete_object(Bucket=self._bucket_name, Key=_key)
Esempio n. 3
0
File: _s3fs.py Progetto: dAnjou/s3fs
 def removedir(self, path):
     self.check()
     _path = self.validatepath(path)
     if _path == '/':
         raise errors.RemoveRootError()
     info = self.getinfo(_path)
     if not info.is_dir:
         raise errors.DirectoryExpected(path)
     if not self.isempty(path):
         raise errors.DirectoryNotEmpty(path)
     _key = self._path_to_dir_key(_path)
     self.s3_delete(self._bucket_name, _key)
Esempio n. 4
0
    def removedir(self, path):  # noqa: D102
        self.check()
        _path = self.validatepath(path)

        # NB: this will raise ResourceNotFound
        # and DirectoryExpected as expected by
        # the specifications
        if not self.isempty(path):
            raise errors.DirectoryNotEmpty(path)

        with convert_sshfs_errors('removedir', path):
            with self._lock:
                self._sftp.rmdir(path)
Esempio n. 5
0
    def removedir(self, path):
        self.check()
        _path = self.validatepath(path)
        if _path == "/":
            raise errors.RemoveRootError()
        info = self.getinfo(_path)
        if not info.is_dir:
            raise errors.DirectoryExpected(path)
        if not self.isempty(_path):
            raise errors.DirectoryNotEmpty(path)

        _key = self._path_to_dir_key(_path)
        with dlkerrors(path):
            self.dlk.rmdir(_key)
    def removedir(self, path: Text) -> None:
        """ Remove a directory. """
        npath = self.normalize_path(path)
        if npath == "/":
            raise errors.RemoveRootError
        if not self.exists(npath):
            raise errors.ResourceNotFound(path)
        if not self.isdir(npath):
            raise errors.DirectoryExpected(path)
        if self.listdir(npath):
            raise errors.DirectoryNotEmpty(path)

        cursor = self.connection.cursor()
        cursor.execute("DELETE FROM sqlar WHERE name LIKE ?", (npath,))
        cursor.close()
Esempio n. 7
0
    def removedir(self, path: str) -> None:
        self.check()
        _path = self.validatepath(path)
        if _path == "/":
            raise errors.RemoveRootError()
        info = self.getinfo(_path)
        if not info.is_dir:
            raise errors.DirectoryExpected(path)
        if not self.isempty(path):
            raise errors.DirectoryNotEmpty(path)
        _key = self._path_to_dir_key(_path)

        try:
            self.bucket.delete_blob(_key)
        except google.cloud.exceptions.NotFound:
            raise errors.ResourceNotFound(path)
Esempio n. 8
0
    def removedir(self, path):
        _path = self.fix_path(path)

        if _path == "/":
            raise errors.RemoveRootError()

        try:
            info = self.getinfo(path)
            if not info.is_dir:
                raise errors.DirectoryExpected(path=path)
            if len(self.listdir(path)) > 0:
                raise errors.DirectoryNotEmpty(path=path)
            self.dropbox.files_delete_v2(_path)
        except ApiError as e:
            if isinstance(e.error._value, LookupError):
                raise errors.ResourceNotFound(path=path)

            raise errors.FileExpected(path=path, exc=e)
Esempio n. 9
0
    def removedir(self, path):
        """
        Remove directory under `path`.

        The directory must be empty.

        :param str path: Path pointing to a directory.
        """
        # type: (Text) -> None

        path = ensureUnicode(path)
        self.check()
        _path = toAscii(self.validatepath(path))
        if _path == "/":
            raise errors.RemoveRootError()
        info = self.getinfo(path)
        if not info.is_dir:
            raise errors.DirectoryExpected(path)
        if not self.isempty(path):
            raise errors.DirectoryNotEmpty(path)

        self._odfs.unlink(_path)
    def removedir(self, path):
        # type: (Text) -> None
        """Remove a directory from the filesystem.

        Arguments:
            path (str): Path of the directory to remove.

        Raises:
            fs.errors.DirectoryNotEmpty: If the directory is not empty (
                see `~fs.base.FS.removetree` for a way to remove the
                directory contents.).
            fs.errors.DirectoryExpected: If the path does not refer to
                a directory.
            fs.errors.ResourceNotFound: If no resource exists at the
                given path.
            fs.errors.RemoveRootError: If an attempt is made to remove
                the root directory (i.e. ``'/'``)

        """
        _path = self.validatepath(path)
        if _path == "/" or _path == "" or _path is None:
            raise errors.RemoveRootError()
        if _path.endswith("/"):
            _path = _path[:-1]

        with self._lock:
            _res = self._getresource(path)
            if not _res:
                raise errors.ResourceNotFound(path)

            if not _res.is_collection:
                raise errors.DirectoryExpected(path)

            if len(_res.get_member_names()) > 0:
                raise errors.DirectoryNotEmpty(path)

            # _res.delete(recursive=False)
            _res.delete()