File tree Expand file tree Collapse file tree
src/ByteSync.Client/Services/Inventories Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,13 +63,7 @@ public bool IsSystemAttribute(FileInfo fileInfo)
6363
6464 public bool IsNoiseFileName ( FileInfo fileInfo , OSPlatforms os )
6565 {
66- var comparison = os == OSPlatforms . Linux ? StringComparison . Ordinal : StringComparison . OrdinalIgnoreCase ;
67-
68- return fileInfo . Name . Equals ( "desktop.ini" , comparison )
69- || fileInfo . Name . Equals ( "thumbs.db" , comparison )
70- || fileInfo . Name . Equals ( ".desktop.ini" , comparison )
71- || fileInfo . Name . Equals ( ".thumbs.db" , comparison )
72- || fileInfo . Name . Equals ( ".DS_Store" , comparison ) ;
66+ return NoiseFileDetector . IsNoiseFileName ( fileInfo . Name , os ) ;
7367 }
7468
7569 public bool IsReparsePoint ( FileSystemInfo fsi )
@@ -120,4 +114,4 @@ private bool SafeIsReparsePoint(FileSystemInfo fsi)
120114 return false ;
121115 }
122116 }
123- }
117+ }
Original file line number Diff line number Diff line change 1+ using ByteSync . Common . Business . Misc ;
2+
3+ namespace ByteSync . Services . Inventories ;
4+
5+ public static class NoiseFileDetector
6+ {
7+ private static readonly string [ ] KnownNoiseFileNames =
8+ [
9+ "desktop.ini" ,
10+ "thumbs.db" ,
11+ "ehthumbs.db" ,
12+ "ehthumbs_vista.db" ,
13+ ".desktop.ini" ,
14+ ".thumbs.db" ,
15+ ".DS_Store" ,
16+ ".AppleDouble" ,
17+ ".LSOverride" ,
18+ ".Spotlight-V100" ,
19+ ".Trashes" ,
20+ ".fseventsd" ,
21+ ".TemporaryItems" ,
22+ ".VolumeIcon.icns" ,
23+ ".directory"
24+ ] ;
25+
26+ private static readonly HashSet < string > CaseSensitiveNoiseFileNames = new ( KnownNoiseFileNames , StringComparer . Ordinal ) ;
27+ private static readonly HashSet < string > CaseInsensitiveNoiseFileNames = new ( KnownNoiseFileNames , StringComparer . OrdinalIgnoreCase ) ;
28+
29+ public static bool IsNoiseFileName ( string ? fileName , OSPlatforms os )
30+ {
31+ if ( string . IsNullOrWhiteSpace ( fileName ) )
32+ {
33+ return false ;
34+ }
35+
36+ return os == OSPlatforms . Linux
37+ ? CaseSensitiveNoiseFileNames . Contains ( fileName )
38+ : CaseInsensitiveNoiseFileNames . Contains ( fileName ) ;
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments