Skip to content
Merged
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
28 changes: 24 additions & 4 deletions rust/lance-io/src/object_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ impl ObjectStore {
let path = Path::parse(&path)?;

if self.is_local() {
// Local file system needs to delete directories as well.
// The local file system provider needs to delete both files and directories.
return super::local::remove_dir_all(&path);
}
let sub_entries = self
Expand All @@ -718,6 +718,11 @@ impl ObjectStore {
.delete_stream(sub_entries)
.try_collect::<Vec<_>>()
.await?;
if self.scheme == "file-object-store" {
// file-object-store tries to do everything as similarly as possible to the remote
// object stores. But we still have to delete the directory entries afterwards.
return super::local::remove_dir_all(&path);
}
Ok(())
}

Expand Down Expand Up @@ -1099,7 +1104,16 @@ mod tests {
}

#[tokio::test]
async fn test_delete_directory() {
async fn test_delete_directory_local_store() {
test_delete_directory("").await;
}

#[tokio::test]
async fn test_delete_directory_file_object_store() {
test_delete_directory("file-object-store").await;
}

async fn test_delete_directory(scheme: &str) {
let path = TempStdDir::default();
create_dir_all(path.join("foo").join("bar")).unwrap();
create_dir_all(path.join("foo").join("zoo")).unwrap();
Expand All @@ -1113,8 +1127,14 @@ mod tests {
"delete",
)
.unwrap();
write_to_file(path.join("foo").join("top").to_str().unwrap(), "delete_top").unwrap();
let (store, base) = ObjectStore::from_uri(path.to_str().unwrap()).await.unwrap();
let url = if scheme.is_empty() {
Url::from_directory_path(&path).unwrap()
} else {
let mut url = Url::parse(&format!("{scheme}:///")).unwrap();
url.set_path(path.to_str().unwrap());
url
};
let (store, base) = ObjectStore::from_uri(url.as_ref()).await.unwrap();
store.remove_dir_all(base.child("foo")).await.unwrap();

assert!(!path.join("foo").exists());
Expand Down
Loading