File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -301,6 +301,13 @@ impl ObjectStore for HdfsObjectStore {
301301 . await
302302 . to_object_store_err ( ) ?;
303303
304+ if status. isdir {
305+ return Err ( HdfsError :: IsADirectoryError (
306+ "Head must be called on a file" . to_string ( ) ,
307+ ) )
308+ . to_object_store_err ( ) ;
309+ }
310+
304311 Ok ( ObjectMeta {
305312 location : location. clone ( ) ,
306313 last_modified : DateTime :: < Utc > :: from_timestamp ( status. modification_time as i64 , 0 )
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ mod test {
3030 file. write ( buf. freeze ( ) ) . await . unwrap ( ) ;
3131 file. close ( ) . await . unwrap ( ) ;
3232
33+ client. mkdirs ( "/testdir" , 0o755 , true ) . await . unwrap ( ) ;
34+
3335 let store = HdfsObjectStore :: new ( Arc :: new ( client) ) ;
3436
3537 test_object_store_head ( & store) . await ?;
@@ -51,6 +53,7 @@ mod test {
5153 assert_eq ! ( head. size, TEST_FILE_INTS * 4 ) ;
5254
5355 assert ! ( store. head( & Path :: from( "/testfile2" ) ) . await . is_err( ) ) ;
56+ assert ! ( store. head( & Path :: from( "/testdir" ) ) . await . is_err( ) ) ;
5457
5558 Ok ( ( ) )
5659 }
You can’t perform that action at this time.
0 commit comments