Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cpp/src/arrow/filesystem/s3fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,9 @@ class S3FileSystem::Impl {
}
// First delete all "files", then delete all child "directories"
RETURN_NOT_OK(DeleteObjects(bucket, file_keys));
// XXX This doesn't seem necessary on Minio
// Delete directories in reverse lexicographic order, to ensure children
// are deleted before their parents (Minio).
std::sort(dir_keys.rbegin(), dir_keys.rend());
return DeleteObjects(bucket, dir_keys);
}

Expand Down
9 changes: 9 additions & 0 deletions cpp/src/arrow/filesystem/s3fs_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,15 @@ class TestS3FSGeneric : public S3TestMixin, public GenericFileSystemTest {
bool allow_move_dir() const override { return false; }
bool allow_append_to_file() const override { return false; }
bool have_directory_mtimes() const override { return false; }
bool have_flaky_directory_tree_deletion() const override {
#ifdef _WIN32
// Recent Minio versions on Windows may not register deletion of all
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created a follow-up JIRA to revisit this issue later https://issues.apache.org/jira/browse/ARROW-8134

// directories in a tree when doing a bulk delete.
return true;
#else
return false;
#endif
}

S3Options options_;
std::shared_ptr<S3FileSystem> s3fs_;
Expand Down
8 changes: 6 additions & 2 deletions cpp/src/arrow/filesystem/test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,17 @@ void GenericFileSystemTest::TestDeleteDirContents(FileSystem* fs) {

// Also with "" (== wipe filesystem)
ASSERT_OK(fs->DeleteDirContents(""));
AssertAllDirs(fs, {});
if (!have_flaky_directory_tree_deletion()) {
AssertAllDirs(fs, {});
}
AssertAllFiles(fs, {});

// Not a directory
CreateFile(fs, "abc", "");
ASSERT_RAISES(IOError, fs->DeleteDirContents("abc"));
AssertAllDirs(fs, {});
if (!have_flaky_directory_tree_deletion()) {
AssertAllDirs(fs, {});
}
AssertAllFiles(fs, {"abc"});
}

Expand Down
2 changes: 2 additions & 0 deletions cpp/src/arrow/filesystem/test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class ARROW_EXPORT GenericFileSystemTest {
virtual bool allow_append_to_file() const { return true; }
// - Whether the filesystem supports directory modification times
virtual bool have_directory_mtimes() const { return true; }
// - Whether some directory tree deletion tests may fail randomly
virtual bool have_flaky_directory_tree_deletion() const { return false; }

void TestEmpty(FileSystem* fs);
void TestCreateDir(FileSystem* fs);
Expand Down