@@ -5,23 +5,39 @@ namespace MatthiWare.UpdateLib.Tasks
55{
66 public class CheckForUpdatedFilesTask : AsyncTask < bool >
77 {
8- private UpdateFile updateFile ;
9- private HashCacheFile cacheFile ;
10- private PathVariableConverter converter ;
8+ private UpdateFile m_updateFile ;
9+ private HashCacheFile m_cacheFile ;
10+ private PathVariableConverter m_converter ;
1111
1212 public CheckForUpdatedFilesTask ( UpdateFile update , HashCacheFile cache , PathVariableConverter converter )
1313 {
14- updateFile = update ;
15- cacheFile = cache ;
16- this . converter = converter ;
14+ if ( update == null ) throw new ArgumentNullException ( nameof ( update ) ) ;
15+ if ( cache == null ) throw new ArgumentNullException ( nameof ( cache ) ) ;
16+ if ( converter == null ) throw new ArgumentNullException ( nameof ( converter ) ) ;
17+
18+ m_updateFile = update ;
19+ m_cacheFile = cache ;
20+ m_converter = converter ;
21+ }
22+
23+ protected override void DoWork ( )
24+ {
25+ Action < DirectoryEntry > call = new Action < DirectoryEntry > ( RecursiveCheck ) ;
26+
27+ foreach ( DirectoryEntry dir in m_updateFile . Folders )
28+ Enqueue ( call , dir ) ;
29+
30+ AwaitWorkers ( ) ;
31+
32+ Result = m_updateFile . Count > 0 ;
1733 }
1834
1935 private void RecursiveCheck ( DirectoryEntry dir )
2036 {
2137 dir . Files . RemoveAll ( fe =>
2238 {
23- string convertedPath = converter . Replace ( fe . DestinationLocation ) ;
24- HashCacheEntry cacheEntry = cacheFile . Items . Find ( hash => hash . FilePath . Equals ( convertedPath ) ) ;
39+ string convertedPath = m_converter . Replace ( fe . DestinationLocation ) ;
40+ HashCacheEntry cacheEntry = m_cacheFile . Items . Find ( hash => hash . FilePath . Equals ( convertedPath ) ) ;
2541
2642 if ( cacheEntry == null )
2743 return false ;
@@ -35,17 +51,5 @@ private void RecursiveCheck(DirectoryEntry dir)
3551 foreach ( DirectoryEntry de in dir . Directories )
3652 Enqueue ( call , de ) ;
3753 }
38-
39- protected override void DoWork ( )
40- {
41- Action < DirectoryEntry > call = new Action < DirectoryEntry > ( RecursiveCheck ) ;
42-
43- foreach ( DirectoryEntry dir in updateFile . Folders )
44- Enqueue ( call , dir ) ;
45-
46- AwaitWorkers ( ) ;
47-
48- Result = updateFile . Count > 0 ;
49- }
5054 }
5155}
0 commit comments