@@ -297,41 +297,17 @@ public static void SyncManager()
297
297
298
298
DownloadedSize = ComponentTracker . Downloaded . Sum ( c => long . Parse ( File . ReadLines ( c . InfoFile ) . First ( ) . Split ( ' ' ) [ 1 ] ) ) ;
299
299
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
-
320
300
IterateXML ( XmlTree . GetElementsByTagName ( "list" ) [ 0 ] . ChildNodes , node =>
321
301
{
322
302
if ( node . Name != "component" ) return ;
323
303
324
304
var component = new Component ( node ) ;
325
-
326
305
bool update = false ;
327
- long oldSize = 0 ;
328
306
329
- if ( ComponentTracker . Downloaded . Any ( item => item . ID == component . ID ) )
307
+ if ( ComponentTracker . Downloaded . Exists ( c => c . ID == component . ID ) )
330
308
{
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 ;
335
311
}
336
312
else if ( component . Required )
337
313
{
@@ -340,19 +316,44 @@ void AddToQueue(Component component, long oldSize)
340
316
341
317
if ( update )
342
318
{
343
- AddToQueue ( component , oldSize ) ;
319
+ ComponentTracker . Outdated . Add ( component ) ;
344
320
345
321
foreach ( string dependID in component . Depends )
346
322
{
347
- if ( ! ComponentTracker . Downloaded . Any ( item => item . ID == dependID ) )
323
+ if ( ! ComponentTracker . Downloaded . Exists ( c => c . ID == dependID ) )
348
324
{
349
325
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 ) ;
351
327
}
352
328
}
353
329
}
354
330
} ) ;
355
331
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
+
356
357
Main . ChangeButton . Text = $ "Apply changes";
357
358
Main . ChangeButton . Enabled = false ;
358
359
@@ -428,7 +429,7 @@ public static bool CheckDependencies(bool alertDepends = true)
428
429
{
429
430
var component = node . Tag as Component ;
430
431
431
- if ( component . Downloaded )
432
+ if ( ComponentTracker . Downloaded . Exists ( c => c . ID == component . ID ) )
432
433
{
433
434
requiredDepends . AddRange ( File . ReadLines ( component . InfoFile ) . First ( ) . Split ( ' ' ) . Skip ( 2 ) . ToArray ( ) ) ;
434
435
}
@@ -450,7 +451,7 @@ public static bool CheckDependencies(bool alertDepends = true)
450
451
{
451
452
node . Checked = true ;
452
453
453
- if ( ComponentTracker . Downloaded . Any ( depend => depend . ID == component . ID ) )
454
+ if ( ComponentTracker . Downloaded . Exists ( depend => depend . ID == component . ID ) )
454
455
{
455
456
persistDepends . Add ( component . Title ) ;
456
457
}
0 commit comments