[
https://issues.apache.org/jira/browse/ARROW-9121?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17152104#comment-17152104
]
Krisztian Szucs edited comment on ARROW-9121 at 7/6/20, 3:42 PM:
-----------------------------------------------------------------
I assume we could have the following raising an error where we advise the user
to use `fs->DeleteRootDirContents()` if that's the real intention:
{code:cpp}
fs->DeleteDirContents("")
fs->DeleteDirContents("/")
fs->DeleteDirContents("//")
{code}
In order to do that we would need a way to check that the normalized path
points to the filesystem root (the prefix in case of subtree filesystem).
was (Author: kszucs):
I assume we could have the following raising an error where we advise the user
to use `fs->DeleteRootDirContents()` if that's the real intention:
{code:cpp}
fs->DeleteDirContents("")
fs->DeleteDirContents("/")
fs->DeleteDirContents("//")
{code}
> [C++] Do not wipe the filesystem when path is empty
> ---------------------------------------------------
>
> Key: ARROW-9121
> URL: https://issues.apache.org/jira/browse/ARROW-9121
> Project: Apache Arrow
> Issue Type: Bug
> Components: C++
> Reporter: Mohamed Zenadi
> Assignee: Krisztian Szucs
> Priority: Minor
> Fix For: 1.0.0
>
>
> The `DeleteDirContents` method in the filesystems api has a default behavior
> or *wiping* the whole filesystem if we give it an empty path.
>
> It's documented as:
> > Like DeleteDir, but doesn’t delete the directory itself. Passing an empty
> path (“”) will wipe the entire filesystem tree.
>
> And the corresponding code confirms that:
> {code:java}
> auto parts = SplitAbstractPath(path);
> RETURN_NOT_OK(ValidateAbstractPathParts(parts));
>
> if (parts.empty()) {
> // Wipe filesystem
> impl_->RootDir().entries.clear();
> return Status::OK();
> }
> {code}
>
> This is a weird default that does not make sense. If the user wanted really
> to wipe his filesystem, he'd pass a `/`.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)