@@ -49,24 +49,24 @@ fn test_purge_caches() -> Result<(), Error> {
49
49
50
50
/// Define which files should be ignored when comparing the two workspaces. If there are expected
51
51
/// changes, update the function to match them.
52
- fn should_ignore ( base : & Path , path : & Path ) -> bool {
52
+ fn should_compare ( base : & Path , path : & Path ) -> bool {
53
53
let components = match path. strip_prefix ( base) {
54
54
Ok ( stripped) => stripped
55
55
. components ( )
56
56
. map ( |component| component. as_os_str ( ) . to_string_lossy ( ) . to_string ( ) )
57
57
. collect :: < Vec < _ > > ( ) ,
58
- Err ( _) => return false ,
58
+ Err ( _) => return true ,
59
59
} ;
60
60
61
61
let components = components. iter ( ) . map ( |c| c. as_str ( ) ) . collect :: < Vec < _ > > ( ) ;
62
62
match components. as_slice ( ) {
63
63
// The indexes could be updated during the build. The index is not considered a cache
64
64
// though, so it's fine to ignore it during the comparison.
65
- [ "cargo-home" , "registry" , "index" , _, ".git" , ..] => true ,
66
- [ "cargo-home" , "registry" , "index" , _, ".cargo-index-lock" ] => true ,
67
- [ "cargo-home" , "registry" , "index" , _, ".last-updated" ] => true ,
65
+ [ "cargo-home" , "registry" , "index" , _, ".git" , ..] => false ,
66
+ [ "cargo-home" , "registry" , "index" , _, ".cargo-index-lock" ] => false ,
67
+ [ "cargo-home" , "registry" , "index" , _, ".last-updated" ] => false ,
68
68
69
- _ => false ,
69
+ _ => true ,
70
70
}
71
71
}
72
72
@@ -80,7 +80,10 @@ impl WorkspaceContents {
80
80
fn collect ( path : & Path ) -> Result < Self , Error > {
81
81
let mut files = HashMap :: new ( ) ;
82
82
83
- for entry in walkdir:: WalkDir :: new ( path) {
83
+ for entry in walkdir:: WalkDir :: new ( path)
84
+ . into_iter ( )
85
+ . filter_entry ( |entry| should_compare ( path, entry. path ( ) ) )
86
+ {
84
87
let entry = entry?;
85
88
let metadata = entry. metadata ( ) ?;
86
89
@@ -103,10 +106,6 @@ impl WorkspaceContents {
103
106
println ! ( "=== start directory differences ===" ) ;
104
107
105
108
for ( path, start_digest) in self . files . into_iter ( ) {
106
- if should_ignore ( & self . base , & path) {
107
- continue ;
108
- }
109
-
110
109
if let Some ( end_digest) = other. files . remove ( & path) {
111
110
if start_digest != end_digest {
112
111
println ! ( "file {} changed its size" , path. display( ) ) ;
@@ -119,10 +118,6 @@ impl WorkspaceContents {
119
118
}
120
119
121
120
for ( path, _) in other. files . into_iter ( ) {
122
- if should_ignore ( & other. base , & path) {
123
- continue ;
124
- }
125
-
126
121
println ! ( "file {} was added" , path. display( ) ) ;
127
122
same = false ;
128
123
}
0 commit comments