@@ -14,7 +14,7 @@ use crate::hdfs::protocol::NamenodeProtocol;
14
14
use crate :: hdfs:: proxy:: NameServiceProxy ;
15
15
use crate :: proto:: hdfs:: hdfs_file_status_proto:: FileType ;
16
16
17
- use crate :: proto:: hdfs:: HdfsFileStatusProto ;
17
+ use crate :: proto:: hdfs:: { ContentSummaryProto , HdfsFileStatusProto } ;
18
18
19
19
#[ derive( Clone ) ]
20
20
pub struct WriteOptions {
@@ -475,6 +475,18 @@ impl Client {
475
475
476
476
Ok ( result)
477
477
}
478
+
479
+ /// Gets a content summary for a file or directory rooted at `path
480
+ pub async fn get_content_summary ( & self , path : & str ) -> Result < ContentSummary > {
481
+ let ( link, resolved_path) = self . mount_table . resolve ( path) ;
482
+ let result = link
483
+ . protocol
484
+ . get_content_summary ( & resolved_path)
485
+ . await ?
486
+ . summary ;
487
+
488
+ Ok ( result. into ( ) )
489
+ }
478
490
}
479
491
480
492
impl Default for Client {
@@ -664,6 +676,29 @@ impl FileStatus {
664
676
}
665
677
}
666
678
679
+ #[ derive( Debug ) ]
680
+ pub struct ContentSummary {
681
+ pub length : u64 ,
682
+ pub file_count : u64 ,
683
+ pub directory_count : u64 ,
684
+ pub quota : u64 ,
685
+ pub space_consumed : u64 ,
686
+ pub space_quota : u64 ,
687
+ }
688
+
689
+ impl From < ContentSummaryProto > for ContentSummary {
690
+ fn from ( value : ContentSummaryProto ) -> Self {
691
+ ContentSummary {
692
+ length : value. length ,
693
+ file_count : value. file_count ,
694
+ directory_count : value. directory_count ,
695
+ quota : value. quota ,
696
+ space_consumed : value. space_consumed ,
697
+ space_quota : value. space_quota ,
698
+ }
699
+ }
700
+ }
701
+
667
702
#[ cfg( test) ]
668
703
mod test {
669
704
use std:: {
0 commit comments