@@ -21,6 +21,9 @@ public class Component : Category
2121 public string Path { get ; set ; }
2222 public string [ ] Depends { get ; set ; } = new string [ ] { } ;
2323
24+ public string InfoFile { get => System . IO . Path . Combine ( FPM . SourcePath , "Components" , $ "{ ID } .txt") ; }
25+ public bool Downloaded { get => File . Exists ( InfoFile ) ; }
26+
2427 public Component ( XmlNode node ) : base ( node )
2528 {
2629 // URL
@@ -293,7 +296,7 @@ public static void SyncManager()
293296 {
294297 var component = node . Tag as Component ;
295298
296- if ( File . Exists ( Path . Combine ( SourcePath , "Components" , $ " { component . ID } .txt" ) ) )
299+ if ( component . Downloaded )
297300 {
298301 ComponentTracker . Downloaded . Add ( component ) ;
299302 node . Checked = true ;
@@ -339,8 +342,7 @@ void AddToQueue(Component component, long oldSize)
339342
340343 if ( ComponentTracker . Downloaded . Any ( item => item . ID == component . ID ) )
341344 {
342- string infoFile = Path . Combine ( SourcePath , "Components" , $ "{ component . ID } .txt") ;
343- string [ ] componentData = File . ReadLines ( infoFile ) . First ( ) . Split ( ' ' ) ;
345+ string [ ] componentData = File . ReadLines ( component . InfoFile ) . First ( ) . Split ( ' ' ) ;
344346
345347 update = componentData [ 0 ] != component . Hash ;
346348 oldSize = long . Parse ( componentData [ 1 ] ) ;
@@ -407,10 +409,7 @@ public static void VerifySourcePath()
407409 {
408410 if ( isFlashpoint || node . Name != "component" ) return ;
409411
410- var component = new Component ( node ) ;
411- string infoPath = Path . Combine ( SourcePath , "Components" , $ "{ component . ID } .txt") ;
412-
413- if ( File . Exists ( infoPath ) )
412+ if ( new Component ( node ) . Downloaded )
414413 {
415414 isFlashpoint = true ;
416415 }
@@ -440,15 +439,14 @@ public static bool CheckDependencies(bool alertDepends = true)
440439 if ( node . Checked && node . Tag . GetType ( ) . ToString ( ) . EndsWith ( "Component" ) )
441440 {
442441 var component = node . Tag as Component ;
443- string infoPath = Path . Combine ( SourcePath , "Components" , $ "{ component . ID } .txt") ;
444-
445- if ( File . Exists ( infoPath ) )
442+
443+ if ( component . Downloaded )
446444 {
447- requiredDepends . AddRange ( File . ReadLines ( infoPath ) . First ( ) . Split ( ' ' ) . Skip ( 2 ) . ToArray ( ) ) ;
445+ requiredDepends . AddRange ( File . ReadLines ( component . InfoFile ) . First ( ) . Split ( ' ' ) . Skip ( 2 ) . ToArray ( ) ) ;
448446 }
449447 else
450448 {
451- requiredDepends . AddRange ( ( node . Tag as Component ) . Depends ) ;
449+ requiredDepends . AddRange ( component . Depends ) ;
452450 }
453451 }
454452 } ) ;
@@ -511,10 +509,9 @@ public static long GetTotalSize(TreeView sourceTree)
511509 if ( node . Checked && node . Tag . GetType ( ) . ToString ( ) . EndsWith ( "Component" ) )
512510 {
513511 var component = node . Tag as Component ;
514- string infoPath = Path . Combine ( SourcePath , "Components" , $ "{ component . ID } .txt") ;
515512
516- size += File . Exists ( infoPath )
517- ? long . Parse ( File . ReadLines ( infoPath ) . First ( ) . Split ( ' ' ) [ 1 ] )
513+ size += component . Downloaded
514+ ? long . Parse ( File . ReadLines ( component . InfoFile ) . First ( ) . Split ( ' ' ) [ 1 ] )
518515 : component . Size ;
519516 }
520517 } ) ;
0 commit comments