@@ -297,41 +297,17 @@ public static void SyncManager()
297297
298298 DownloadedSize = ComponentTracker . Downloaded . Sum ( c => long . Parse ( File . ReadLines ( c . InfoFile ) . First ( ) . Split ( ' ' ) [ 1 ] ) ) ;
299299
300- long totalSizeChange = 0 ;
301-
302- void AddToQueue ( Component component , long oldSize )
303- {
304- long sizeChange = component . Size - oldSize ;
305- totalSizeChange += sizeChange ;
306-
307- string displayedSize = GetFormattedBytes ( sizeChange ) ;
308- if ( displayedSize [ 0 ] != '-' ) displayedSize = "+" + displayedSize ;
309-
310- var item = new ListViewItem ( ) ;
311- item . Text = component . Title ;
312- item . SubItems . Add ( component . Description ) ;
313- item . SubItems . Add ( component . LastUpdated ) ;
314- item . SubItems . Add ( displayedSize ) ;
315-
316- Main . UpdateList . Items . Add ( item ) ;
317- ComponentTracker . Outdated . Add ( component ) ;
318- }
319-
320300 IterateXML ( XmlTree . GetElementsByTagName ( "list" ) [ 0 ] . ChildNodes , node =>
321301 {
322302 if ( node . Name != "component" ) return ;
323303
324304 var component = new Component ( node ) ;
325-
326305 bool update = false ;
327- long oldSize = 0 ;
328306
329- if ( ComponentTracker . Downloaded . Any ( item => item . ID == component . ID ) )
307+ if ( ComponentTracker . Downloaded . Exists ( c => c . ID == component . ID ) )
330308 {
331- string [ ] componentData = File . ReadLines ( component . InfoFile ) . First ( ) . Split ( ' ' ) ;
332-
333- update = componentData [ 0 ] != component . Hash ;
334- oldSize = long . Parse ( componentData [ 1 ] ) ;
309+ string localHash = File . ReadLines ( component . InfoFile ) . First ( ) . Split ( ' ' ) [ 0 ] ;
310+ update = localHash != component . Hash ;
335311 }
336312 else if ( component . Required )
337313 {
@@ -340,19 +316,44 @@ void AddToQueue(Component component, long oldSize)
340316
341317 if ( update )
342318 {
343- AddToQueue ( component , oldSize ) ;
319+ ComponentTracker . Outdated . Add ( component ) ;
344320
345321 foreach ( string dependID in component . Depends )
346322 {
347- if ( ! ComponentTracker . Downloaded . Any ( item => item . ID == dependID ) )
323+ if ( ! ComponentTracker . Downloaded . Exists ( c => c . ID == dependID ) )
348324 {
349325 var query = Main . ComponentList . Nodes . Find ( dependID , true ) ;
350- if ( query . Length > 0 ) AddToQueue ( query [ 0 ] . Tag as Component , 0 ) ;
326+ if ( query . Length > 0 ) ComponentTracker . Outdated . Add ( query [ 0 ] . Tag as Component ) ;
351327 }
352328 }
353329 }
354330 } ) ;
355331
332+ ComponentTracker . Outdated = ComponentTracker . Outdated . Distinct ( ) . ToList ( ) ;
333+
334+ long totalSizeChange = 0 ;
335+
336+ foreach ( var component in ComponentTracker . Outdated )
337+ {
338+ long oldSize = ComponentTracker . Downloaded . Exists ( c => c . ID == component . ID )
339+ ? long . Parse ( File . ReadLines ( component . InfoFile ) . First ( ) . Split ( ' ' ) [ 1 ] )
340+ : 0 ;
341+
342+ long sizeChange = component . Size - oldSize ;
343+ totalSizeChange += sizeChange ;
344+
345+ string displayedSize = GetFormattedBytes ( sizeChange ) ;
346+ if ( displayedSize [ 0 ] != '-' ) displayedSize = "+" + displayedSize ;
347+
348+ var item = new ListViewItem ( ) ;
349+ item . Text = component . Title ;
350+ item . SubItems . Add ( component . Description ) ;
351+ item . SubItems . Add ( component . LastUpdated ) ;
352+ item . SubItems . Add ( displayedSize ) ;
353+
354+ Main . UpdateList . Items . Add ( item ) ;
355+ }
356+
356357 Main . ChangeButton . Text = $ "Apply changes";
357358 Main . ChangeButton . Enabled = false ;
358359
@@ -428,7 +429,7 @@ public static bool CheckDependencies(bool alertDepends = true)
428429 {
429430 var component = node . Tag as Component ;
430431
431- if ( component . Downloaded )
432+ if ( ComponentTracker . Downloaded . Exists ( c => c . ID == component . ID ) )
432433 {
433434 requiredDepends . AddRange ( File . ReadLines ( component . InfoFile ) . First ( ) . Split ( ' ' ) . Skip ( 2 ) . ToArray ( ) ) ;
434435 }
@@ -450,7 +451,7 @@ public static bool CheckDependencies(bool alertDepends = true)
450451 {
451452 node . Checked = true ;
452453
453- if ( ComponentTracker . Downloaded . Any ( depend => depend . ID == component . ID ) )
454+ if ( ComponentTracker . Downloaded . Exists ( depend => depend . ID == component . ID ) )
454455 {
455456 persistDepends . Add ( component . Title ) ;
456457 }
0 commit comments