Skip to content

Commit

Permalink
Fix bug in clean prefix detection (#761)
Browse files Browse the repository at this point in the history
  • Loading branch information
paraseba authored Feb 20, 2025
1 parent 880f37d commit 8dfd099
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 30 deletions.
4 changes: 0 additions & 4 deletions icechunk/src/storage/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,6 @@ impl Storage for LoggingStorage {
self.backend.get_snapshot_last_modified(settings, snapshot).await
}

async fn root_is_clean(&self) -> StorageResult<bool> {
self.backend.root_is_clean().await
}

async fn get_object_range_buf(
&self,
key: &str,
Expand Down
4 changes: 3 additions & 1 deletion icechunk/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ pub trait Storage: fmt::Debug + private::Sealed + Sync + Send {
snapshot: &SnapshotId,
) -> StorageResult<DateTime<Utc>>;

async fn root_is_clean(&self) -> StorageResult<bool>;
async fn root_is_clean(&self) -> StorageResult<bool> {
Ok(self.list_objects(&Settings::default(), "").await?.next().await.is_none())
}

async fn list_chunks(
&self,
Expand Down
11 changes: 0 additions & 11 deletions icechunk/src/storage/object_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,17 +583,6 @@ impl Storage for ObjectStorage {
Ok(res.last_modified)
}

#[instrument(skip(self))]
async fn root_is_clean(&self) -> StorageResult<bool> {
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,
Expand Down
14 changes: 0 additions & 14 deletions icechunk/src/storage/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,20 +639,6 @@ impl Storage for S3Storage {
Ok(res)
}

#[instrument(skip(self))]
async fn root_is_clean(&self) -> StorageResult<bool> {
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,
Expand Down

0 comments on commit 8dfd099

Please sign in to comment.