Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ impl ObjectStore for HdfsObjectStore {
.await
.to_object_store_err()?;

if status.isdir {
return Err(HdfsError::IsADirectoryError(
"Head must be called on a file".to_string(),
))
.to_object_store_err();
}

Ok(ObjectMeta {
location: location.clone(),
last_modified: DateTime::<Utc>::from_timestamp(status.modification_time as i64, 0)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_object_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ mod test {
file.write(buf.freeze()).await.unwrap();
file.close().await.unwrap();

client.mkdirs("/testdir", 0o755, true).await.unwrap();

let store = HdfsObjectStore::new(Arc::new(client));

test_object_store_head(&store).await?;
Expand All @@ -51,6 +53,7 @@ mod test {
assert_eq!(head.size, TEST_FILE_INTS * 4);

assert!(store.head(&Path::from("/testfile2")).await.is_err());
assert!(store.head(&Path::from("/testdir")).await.is_err());

Ok(())
}
Expand Down
Loading