@@ -84,12 +84,19 @@ fn strip_prefix(prefix: &Path, path: Path) -> Path {
8484
8585/// Strip the constant prefix from a given ObjectMeta
8686fn strip_meta ( prefix : & Path , meta : ObjectMeta ) -> ObjectMeta {
87+ let ObjectMeta {
88+ last_modified,
89+ size,
90+ location,
91+ e_tag,
92+ version,
93+ } = meta;
8794 ObjectMeta {
88- last_modified : meta . last_modified ,
89- size : meta . size ,
90- location : strip_prefix ( prefix, meta . location ) ,
91- e_tag : meta . e_tag ,
92- version : None ,
95+ last_modified,
96+ size,
97+ location : strip_prefix ( prefix, location) ,
98+ e_tag,
99+ version,
93100 }
94101}
95102
@@ -321,6 +328,32 @@ mod tests {
321328 store. get ( & head. location ) . await . unwrap ( ) ;
322329 }
323330
331+ #[ test]
332+ fn strip_meta_preserves_version_and_etag ( ) {
333+ let prefix = Path :: from ( "prefix" ) ;
334+ let meta = ObjectMeta {
335+ location : Path :: from ( "prefix/foo" ) ,
336+ last_modified : chrono:: DateTime :: from_timestamp ( 1_700_000_000 , 0 ) . unwrap ( ) ,
337+ size : 42 ,
338+ e_tag : Some ( "etag-value" . to_string ( ) ) ,
339+ version : Some ( "version-value" . to_string ( ) ) ,
340+ } ;
341+
342+ let ObjectMeta {
343+ location,
344+ last_modified,
345+ size,
346+ e_tag,
347+ version,
348+ } = strip_meta ( & prefix, meta. clone ( ) ) ;
349+
350+ assert_eq ! ( location, Path :: from( "foo" ) ) ;
351+ assert_eq ! ( last_modified, meta. last_modified) ;
352+ assert_eq ! ( size, meta. size) ;
353+ assert_eq ! ( e_tag, meta. e_tag) ;
354+ assert_eq ! ( version, meta. version) ;
355+ }
356+
324357 #[ tokio:: test]
325358 async fn prefix_multipart ( ) {
326359 let store = PrefixStore :: new ( InMemory :: new ( ) , "prefix" ) ;
0 commit comments