@@ -47,7 +47,17 @@ impl ContentDirectory {
47
47
let mut files = Vec :: new ( ) ;
48
48
let walker = WalkDir :: new ( absolute_root_path)
49
49
. follow_links ( true )
50
- . min_depth ( 1 ) ;
50
+ . min_depth ( 1 )
51
+ . into_iter ( )
52
+ . filter_entry ( |entry| {
53
+ // Skip hidden files/directories.
54
+ let is_hidden = entry
55
+ . file_name ( )
56
+ . to_str ( )
57
+ . map ( |name| name. starts_with ( '.' ) )
58
+ . unwrap_or ( false ) ;
59
+ !is_hidden
60
+ } ) ;
51
61
for dir_entry_result in walker {
52
62
let dir_entry = dir_entry_result. map_err ( |walkdir_error| {
53
63
ContentDirectoryFromRootError :: WalkDirError {
@@ -82,7 +92,6 @@ impl ContentDirectory {
82
92
pub struct ContentFile {
83
93
absolute_path : String ,
84
94
relative_path : String ,
85
- is_hidden : bool ,
86
95
is_executable : bool ,
87
96
relative_path_without_extensions : String ,
88
97
extensions : Vec < String > ,
@@ -154,25 +163,21 @@ impl ContentFile {
154
163
// differ across platforms. It wouldn't be hard to implement this, but
155
164
// Operator does not currently run its CI checks on non-unix platforms
156
165
// so it would be too easy to introduce regressions.
157
- let ( extensions, is_hidden , is_executable) = if !cfg ! ( unix) {
166
+ let ( extensions, is_executable) = if !cfg ! ( unix) {
158
167
return Err ( ContentFileError ( format ! (
159
168
"Operator does not currently support your operating system ({})" ,
160
169
env:: consts:: OS ,
161
170
) ) ) ;
162
171
} else {
163
- // If the basename begins with `.` its first chunk isn't considered an "extension".
172
+ // If the basename begins with `.` its first chunk isn't considered
173
+ // an "extension".
164
174
let non_extension_components = if basename. starts_with ( '.' ) { 2 } else { 1 } ;
165
175
let extensions = basename
166
176
. split ( '.' )
167
177
. skip ( non_extension_components)
168
178
. map ( String :: from)
169
179
. collect :: < Vec < String > > ( ) ;
170
180
171
- // The file is hidden if any of its relative path components starts
172
- // with a dot.
173
- let is_hidden = relative_path. starts_with ( '.' )
174
- || relative_path. contains ( & format ! ( "{}." , Self :: PATH_SEPARATOR ) ) ;
175
-
176
181
let permissions = file
177
182
. metadata ( )
178
183
. map_err ( |io_error| {
@@ -185,7 +190,7 @@ impl ContentFile {
185
190
. permissions ( ) ;
186
191
let is_executable = permissions. mode ( ) & 0o111 != 0 ;
187
192
188
- ( extensions, is_hidden , is_executable)
193
+ ( extensions, is_executable)
189
194
} ;
190
195
191
196
let relative_path_without_extensions = String :: from ( {
@@ -202,7 +207,6 @@ impl ContentFile {
202
207
relative_path_without_extensions,
203
208
extensions,
204
209
file,
205
- is_hidden,
206
210
is_executable,
207
211
} )
208
212
}
@@ -215,10 +219,6 @@ impl ContentFile {
215
219
& self . relative_path
216
220
}
217
221
218
- pub fn is_hidden ( & self ) -> bool {
219
- self . is_hidden
220
- }
221
-
222
222
pub fn is_executable ( & self ) -> bool {
223
223
self . is_executable
224
224
}
0 commit comments