File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7272 path : root,
7373
7474 get_info : |path| {
75- let stats = match symlink_metadata ( path) {
75+ let ( is_dir , size ) = match symlink_metadata ( path) {
7676 Err ( error) => {
7777 reporter. report ( Event :: EncounterError ( ErrorReport {
7878 operation : SymlinkMetadata ,
@@ -84,10 +84,16 @@ where
8484 children : Vec :: new ( ) ,
8585 } ;
8686 }
87- Ok ( stats) => stats,
87+ Ok ( stats) => {
88+ // `stats` should be dropped ASAP to avoid piling up kernel memory usage
89+ let is_dir = stats. is_dir ( ) ;
90+ let size = size_getter. get_size ( & stats) ;
91+ reporter. report ( Event :: ReceiveData ( size) ) ;
92+ ( is_dir, size)
93+ }
8894 } ;
8995
90- let children: Vec < _ > = if stats . is_dir ( ) {
96+ let children: Vec < _ > = if is_dir {
9197 match read_dir ( path) {
9298 Err ( error) => {
9399 reporter. report ( Event :: EncounterError ( ErrorReport {
@@ -115,9 +121,6 @@ where
115121 Vec :: new ( )
116122 } ;
117123
118- let size = size_getter. get_size ( & stats) ;
119- reporter. report ( Event :: ReceiveData ( size) ) ;
120-
121124 Info { size, children }
122125 } ,
123126
You can’t perform that action at this time.
0 commit comments