Skip to content

rmdir deletes non-empty prefixes and buckets #205

@ValentinBilla

Description

@ValentinBilla

Reading the tests, this seems to be by design but the docstring in the method says the contrary which is aligned with Path.rmdir's behavior.

def rmdir(self):
"""
Removes this Bucket / key prefix. The Bucket / key prefix must be empty
"""
self._absolute_path_validation()
if self.is_file():
raise NotADirectoryError()
if not self.is_dir():
raise FileNotFoundError()
accessor.rmdir(self)

This might cause unintended deletion of existing files

Still the current behavior can be quite helpful in lots of cases and I wonder if maybe we could either add some kind of force: bool parameter to the function or creating a rmtree function akin to shutil.rmtree to ensure no mistakes are made and keep this great bit of functionnality

I'm available for contributions if any these changes were to be approved

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions