From 8dfd099888b07da4a529c6b1daab21bd468005c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Galkin?= Date: Thu, 20 Feb 2025 12:47:42 -0300 Subject: [PATCH] Fix bug in clean prefix detection (#761) --- icechunk/src/storage/logging.rs | 4 ---- icechunk/src/storage/mod.rs | 4 +++- icechunk/src/storage/object_store.rs | 11 ----------- icechunk/src/storage/s3.rs | 14 -------------- 4 files changed, 3 insertions(+), 30 deletions(-) diff --git a/icechunk/src/storage/logging.rs b/icechunk/src/storage/logging.rs index 89aae1f1..1eefc066 100644 --- a/icechunk/src/storage/logging.rs +++ b/icechunk/src/storage/logging.rs @@ -209,10 +209,6 @@ impl Storage for LoggingStorage { self.backend.get_snapshot_last_modified(settings, snapshot).await } - async fn root_is_clean(&self) -> StorageResult { - self.backend.root_is_clean().await - } - async fn get_object_range_buf( &self, key: &str, diff --git a/icechunk/src/storage/mod.rs b/icechunk/src/storage/mod.rs index 09cffbd7..67ff4ef3 100644 --- a/icechunk/src/storage/mod.rs +++ b/icechunk/src/storage/mod.rs @@ -363,7 +363,9 @@ pub trait Storage: fmt::Debug + private::Sealed + Sync + Send { snapshot: &SnapshotId, ) -> StorageResult>; - async fn root_is_clean(&self) -> StorageResult; + async fn root_is_clean(&self) -> StorageResult { + Ok(self.list_objects(&Settings::default(), "").await?.next().await.is_none()) + } async fn list_chunks( &self, diff --git a/icechunk/src/storage/object_store.rs b/icechunk/src/storage/object_store.rs index 38ee9f41..d85ea694 100644 --- a/icechunk/src/storage/object_store.rs +++ b/icechunk/src/storage/object_store.rs @@ -583,17 +583,6 @@ impl Storage for ObjectStorage { Ok(res.last_modified) } - #[instrument(skip(self))] - async fn root_is_clean(&self) -> StorageResult { - Ok(self - .get_client() - .await - .list(Some(&ObjectPath::from(self.backend.prefix()))) - .next() - .await - .is_none()) - } - #[instrument(skip(self))] async fn get_object_range_buf( &self, diff --git a/icechunk/src/storage/s3.rs b/icechunk/src/storage/s3.rs index be105a21..33b2c196 100644 --- a/icechunk/src/storage/s3.rs +++ b/icechunk/src/storage/s3.rs @@ -639,20 +639,6 @@ impl Storage for S3Storage { Ok(res) } - #[instrument(skip(self))] - async fn root_is_clean(&self) -> StorageResult { - let res = self - .get_client() - .await - .list_objects_v2() - .bucket(self.bucket.clone()) - .prefix(self.prefix.clone()) - .max_keys(1) - .send() - .await?; - Ok(res.contents.map(|v| v.is_empty()).unwrap_or(true)) - } - #[instrument(skip(self))] async fn get_object_range_buf( &self,