11use std:: collections:: VecDeque ;
22use std:: os:: windows:: fs:: MetadataExt ;
33use std:: path:: { Path , PathBuf } ;
4- use std:: sync:: Mutex ;
54use std:: time:: { Duration , Instant } ;
65
76use filesize:: file_real_size;
@@ -154,14 +153,14 @@ impl GroupInfo {
154153#[ derive( Debug ) ]
155154pub struct FolderScan {
156155 path : PathBuf ,
157- excludes : Mutex < GlobSet > ,
156+ excludes : GlobSet ,
158157}
159158
160159impl FolderScan {
161160 pub fn new < P : AsRef < Path > > ( path : P , excludes : GlobSet ) -> Self {
162161 Self {
163162 path : path. as_ref ( ) . to_path_buf ( ) ,
164- excludes : Mutex :: new ( excludes ) ,
163+ excludes,
165164 }
166165 }
167166}
@@ -170,9 +169,9 @@ impl Background for FolderScan {
170169 type Output = Result < FolderInfo , FolderInfo > ;
171170 type Status = ( PathBuf , FolderSummary ) ;
172171
173- fn run ( & self , control : & ControlToken < Self :: Status > ) -> Self :: Output {
174- let mut ds = FolderInfo :: new ( & self . path ) ;
175- let excludes = self . excludes . lock ( ) . expect ( "exclude lock" ) ;
172+ fn run ( self , control : & ControlToken < Self :: Status > ) -> Self :: Output {
173+ let FolderScan { path , excludes } = self ;
174+ let mut ds = FolderInfo :: new ( & path ) ;
176175 let incompressible = pathdb ( ) ;
177176 let mut incompressible = incompressible. write ( ) . unwrap ( ) ;
178177 let _ = incompressible. load ( ) ;
@@ -186,7 +185,7 @@ impl Background for FolderScan {
186185 // 4. Grab metadata - should be infallible on Windows, it comes with the
187186 // DirEntry.
188187 // 5. GetCompressedFileSizeW() or skip.
189- let walker = WalkDir :: new ( & self . path )
188+ let walker = WalkDir :: new ( & path)
190189 . into_iter ( )
191190 . filter_entry ( |e| e. file_type ( ) . is_file ( ) || !excludes. is_match ( e. path ( ) ) )
192191 . filter_map ( |e| e. map_err ( |e| eprintln ! ( "Error: {:?}" , e) ) . ok ( ) )
@@ -198,7 +197,7 @@ impl Background for FolderScan {
198197 for ( count, ( entry, metadata, physical) ) in walker {
199198 let shortname = entry
200199 . path ( )
201- . strip_prefix ( & self . path )
200+ . strip_prefix ( & path)
202201 . unwrap_or_else ( |_e| entry. path ( ) )
203202 . to_path_buf ( ) ;
204203
0 commit comments