File tree 2 files changed +10
-0
lines changed
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 {
301
301
. await
302
302
. to_object_store_err ( ) ?;
303
303
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
+
304
311
Ok ( ObjectMeta {
305
312
location : location. clone ( ) ,
306
313
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 {
30
30
file. write ( buf. freeze ( ) ) . await . unwrap ( ) ;
31
31
file. close ( ) . await . unwrap ( ) ;
32
32
33
+ client. mkdirs ( "/testdir" , 0o755 , true ) . await . unwrap ( ) ;
34
+
33
35
let store = HdfsObjectStore :: new ( Arc :: new ( client) ) ;
34
36
35
37
test_object_store_head ( & store) . await ?;
@@ -51,6 +53,7 @@ mod test {
51
53
assert_eq ! ( head. size, TEST_FILE_INTS * 4 ) ;
52
54
53
55
assert ! ( store. head( & Path :: from( "/testfile2" ) ) . await . is_err( ) ) ;
56
+ assert ! ( store. head( & Path :: from( "/testdir" ) ) . await . is_err( ) ) ;
54
57
55
58
Ok ( ( ) )
56
59
}
You can’t perform that action at this time.
0 commit comments