@@ -834,9 +834,6 @@ pub trait ObjectStore: std::fmt::Display + Send + Sync + Debug + 'static {
834834 . await
835835 }
836836
837- /// Delete the object at the specified location.
838- async fn delete ( & self , location : & Path ) -> Result < ( ) > ;
839-
840837 /// Delete all the objects at the specified locations
841838 ///
842839 /// When supported, this method will use bulk operations that delete more
@@ -939,10 +936,6 @@ pub trait ObjectStore: std::fmt::Display + Send + Sync + Debug + 'static {
939936 /// # todo!()
940937 /// # }
941938 /// #
942- /// # async fn delete(&self, _: &Path) -> Result<()> {
943- /// # todo!()
944- /// # }
945- /// #
946939 /// fn delete_stream(
947940 /// &self,
948941 /// locations: BoxStream<'static, Result<Path>>,
@@ -1100,10 +1093,6 @@ macro_rules! as_ref_impl {
11001093 self . as_ref( ) . get_ranges( location, ranges) . await
11011094 }
11021095
1103- async fn delete( & self , location: & Path ) -> Result <( ) > {
1104- self . as_ref( ) . delete( location) . await
1105- }
1106-
11071096 fn delete_stream(
11081097 & self ,
11091098 locations: BoxStream <' static , Result <Path >>,
@@ -1243,6 +1232,9 @@ pub trait ObjectStoreExt: ObjectStore {
12431232
12441233 /// Return the metadata for the specified location
12451234 fn head ( & self , location : & Path ) -> impl Future < Output = Result < ObjectMeta > > ;
1235+
1236+ /// Delete the object at the specified location.
1237+ fn delete ( & self , location : & Path ) -> impl Future < Output = Result < ( ) > > ;
12461238}
12471239
12481240impl < T > ObjectStoreExt for T
@@ -1272,6 +1264,24 @@ where
12721264 let options = GetOptions :: new ( ) . with_head ( true ) ;
12731265 Ok ( self . get_opts ( location, options) . await ?. meta )
12741266 }
1267+
1268+ async fn delete ( & self , location : & Path ) -> Result < ( ) > {
1269+ let location = location. clone ( ) ;
1270+ let mut stream =
1271+ self . delete_stream ( futures:: stream:: once ( async move { Ok ( location) } ) . boxed ( ) ) ;
1272+ let _path = stream. try_next ( ) . await ?. ok_or_else ( || Error :: Generic {
1273+ store : "ext" ,
1274+ source : "`delete_stream` was supposed to yield once but didn't" . into ( ) ,
1275+ } ) ?;
1276+ if stream. next ( ) . await . is_some ( ) {
1277+ Err ( Error :: Generic {
1278+ store : "ext" ,
1279+ source : "`delete_stream` yielded more than once" . into ( ) ,
1280+ } )
1281+ } else {
1282+ Ok ( ( ) )
1283+ }
1284+ }
12751285}
12761286
12771287/// Result of a list call that includes objects, prefixes (directories) and a
0 commit comments