Skip to content

Commit bb9021c

Browse files
authored
refactor!: move head to ObjectStoreExt (#543)
1 parent fa48f9a commit bb9021c

File tree

7 files changed

+9
-43
lines changed

7 files changed

+9
-43
lines changed

src/chunked.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,6 @@ impl ObjectStore for ChunkedStore {
139139
self.inner.get_ranges(location, ranges).await
140140
}
141141

142-
async fn head(&self, location: &Path) -> Result<ObjectMeta> {
143-
self.inner.head(location).await
144-
}
145-
146142
async fn delete(&self, location: &Path) -> Result<()> {
147143
self.inner.delete(location).await
148144
}

src/lib.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -834,12 +834,6 @@ pub trait ObjectStore: std::fmt::Display + Send + Sync + Debug + 'static {
834834
.await
835835
}
836836

837-
/// Return the metadata for the specified location
838-
async fn head(&self, location: &Path) -> Result<ObjectMeta> {
839-
let options = GetOptions::new().with_head(true);
840-
Ok(self.get_opts(location, options).await?.meta)
841-
}
842-
843837
/// Delete the object at the specified location.
844838
async fn delete(&self, location: &Path) -> Result<()>;
845839

@@ -1106,10 +1100,6 @@ macro_rules! as_ref_impl {
11061100
self.as_ref().get_ranges(location, ranges).await
11071101
}
11081102

1109-
async fn head(&self, location: &Path) -> Result<ObjectMeta> {
1110-
self.as_ref().head(location).await
1111-
}
1112-
11131103
async fn delete(&self, location: &Path) -> Result<()> {
11141104
self.as_ref().delete(location).await
11151105
}
@@ -1250,6 +1240,9 @@ pub trait ObjectStoreExt: ObjectStore {
12501240
/// }
12511241
/// ```
12521242
fn get_range(&self, location: &Path, range: Range<u64>) -> impl Future<Output = Result<Bytes>>;
1243+
1244+
/// Return the metadata for the specified location
1245+
fn head(&self, location: &Path) -> impl Future<Output = Result<ObjectMeta>>;
12531246
}
12541247

12551248
impl<T> ObjectStoreExt for T
@@ -1274,6 +1267,11 @@ where
12741267
let options = GetOptions::new().with_range(Some(range));
12751268
self.get_opts(location, options).await?.bytes().await
12761269
}
1270+
1271+
async fn head(&self, location: &Path) -> Result<ObjectMeta> {
1272+
let options = GetOptions::new().with_head(true);
1273+
Ok(self.get_opts(location, options).await?.meta)
1274+
}
12771275
}
12781276

12791277
/// Result of a list call that includes objects, prefixes (directories) and a

src/limit.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,6 @@ impl<T: ObjectStore> ObjectStore for LimitStore<T> {
105105
self.inner.get_ranges(location, ranges).await
106106
}
107107

108-
async fn head(&self, location: &Path) -> Result<ObjectMeta> {
109-
let _permit = self.semaphore.acquire().await.unwrap();
110-
self.inner.head(location).await
111-
}
112-
113108
async fn delete(&self, location: &Path) -> Result<()> {
114109
let _permit = self.semaphore.acquire().await.unwrap();
115110
self.inner.delete(location).await

src/local.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,7 @@ mod unix_test {
17471747
use tempfile::TempDir;
17481748

17491749
use crate::local::LocalFileSystem;
1750-
use crate::{ObjectStore, ObjectStoreExt, Path};
1750+
use crate::{ObjectStoreExt, Path};
17511751

17521752
#[tokio::test]
17531753
async fn test_fifo() {

src/memory.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,6 @@ impl ObjectStore for InMemory {
294294
.collect()
295295
}
296296

297-
async fn head(&self, location: &Path) -> Result<ObjectMeta> {
298-
let entry = self.entry(location)?;
299-
300-
Ok(ObjectMeta {
301-
location: location.clone(),
302-
last_modified: entry.last_modified,
303-
size: entry.data.len() as u64,
304-
e_tag: Some(entry.e_tag.to_string()),
305-
version: None,
306-
})
307-
}
308-
309297
async fn delete(&self, location: &Path) -> Result<()> {
310298
self.storage.write().map.remove(location);
311299
Ok(())

src/prefix.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,6 @@ impl<T: ObjectStore> ObjectStore for PrefixStore<T> {
124124
self.inner.get_ranges(&full_path, ranges).await
125125
}
126126

127-
async fn head(&self, location: &Path) -> Result<ObjectMeta> {
128-
let full_path = self.full_path(location);
129-
let meta = self.inner.head(&full_path).await?;
130-
Ok(self.strip_meta(meta))
131-
}
132-
133127
async fn delete(&self, location: &Path) -> Result<()> {
134128
let full_path = self.full_path(location);
135129
self.inner.delete(&full_path).await

src/throttle.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,6 @@ impl<T: ObjectStore> ObjectStore for ThrottledStore<T> {
193193
self.inner.get_ranges(location, ranges).await
194194
}
195195

196-
async fn head(&self, location: &Path) -> Result<ObjectMeta> {
197-
sleep(self.config().wait_put_per_call).await;
198-
self.inner.head(location).await
199-
}
200-
201196
async fn delete(&self, location: &Path) -> Result<()> {
202197
sleep(self.config().wait_delete_per_call).await;
203198

0 commit comments

Comments
 (0)