@@ -59,16 +59,16 @@ public string SettingsBankFolderPath
59
59
get => SwapPathFolder + "\\ " + SettingsBankFolderName ;
60
60
}
61
61
62
- public PreferencesXML ForPreferencesXML { get ; init ; }
62
+ public AppEntrySaveHandler AppEntrySaveHandler { get ; init ; }
63
63
64
- public FileSwapper ( AppEntry appEntry , PreferencesXML preferencesXML )
64
+ public FileSwapper ( AppEntry appEntry , AppEntrySaveHandler appEntrySaveHandler )
65
65
{
66
66
AppEntry = appEntry ;
67
- ForPreferencesXML = preferencesXML ;
67
+ appEntrySaveHandler = AppEntrySaveHandler ;
68
68
}
69
69
70
70
71
- public async Task InitiateFileSwaps ( PowerLineStatus forPowerLineStatus , PreferencesXML preferencesXML )
71
+ public async Task InitiateFileSwaps ( PowerLineStatus forPowerLineStatus , AppEntrySaveHandler appEntrySaveHandler )
72
72
{
73
73
Logger . inst . Log ( $ "Initiating File Swaps for AppEntry with target path { AppEntry . AppPath } ") ;
74
74
@@ -153,7 +153,7 @@ private async Task InitiateSingleFileSwap(FileSwapPathTask fileSwapPathTask, int
153
153
154
154
string swapPath = fileSwapPathTask . FileSwapPath ;
155
155
PowerLineStatus forPowerLineStatus = fileSwapPathTask . ForPowerLineStatus ;
156
- PreferencesXML preferencesXML = ForPreferencesXML ;
156
+ AppEntrySaveHandler forAppEntrySaveHandler = AppEntrySaveHandler ;
157
157
158
158
//use caution when modifying the sequence of logic here and note where this block is placed
159
159
WaitForOlderFileSwaps :
@@ -258,7 +258,10 @@ private async Task InitiateSingleFileSwap(FileSwapPathTask fileSwapPathTask, int
258
258
AppEntry modified = AppEntry ; //struct copy
259
259
modified . SwapperStates [ swapPathIndex ] = PowerLineStatus . Offline ;
260
260
261
- preferencesXML . ModifyAppEntryAndSave ( AppEntry . AppPath , modified ) ;
261
+ //await new Task(new Action( () => preferencesXML.ModifyAppEntryAndSave(AppEntry.AppPath, modified)));
262
+ AppEntrySaveHandler . ChangeAppEntryByPath ( AppEntry . AppPath , modified ) ;
263
+ AppEntrySaveHandler . SaveAppEntryChanges ( ) ;
264
+
262
265
string s3 = $ "Saved SwapPath state for SwapPath { swapPath } for app { AppEntry . AppPath } ";
263
266
Logger . inst . Log ( s3 ) ;
264
267
} else
@@ -303,7 +306,8 @@ private async Task InitiateSingleFileSwap(FileSwapPathTask fileSwapPathTask, int
303
306
AppEntry modified = AppEntry ; //struct copy
304
307
modified . SwapperStates [ swapPathIndex ] = PowerLineStatus . Online ;
305
308
306
- preferencesXML . ModifyAppEntryAndSave ( AppEntry . AppPath , modified ) ;
309
+ AppEntrySaveHandler . ChangeAppEntryByPath ( AppEntry . AppPath , modified ) ;
310
+ AppEntrySaveHandler . SaveAppEntryChanges ( ) ;
307
311
string s3 = $ "Saved SwapPath state for SwapPath { swapPath } for app { AppEntry . AppPath } ";
308
312
Logger . inst . Log ( s3 ) ;
309
313
} else
@@ -472,15 +476,15 @@ public static Task CopyToAsync(string source, string destination)
472
476
}
473
477
*/
474
478
475
- public static string [ ] GetOrphanedSwapPathFoldersFor ( AppEntry appEntry , PreferencesXML forPreferencesXML )
479
+ public static string [ ] GetOrphanedSwapPathFoldersFor ( AppEntry appEntry , AppEntrySaveHandler forAppEntrySaveHandler )
476
480
{
477
481
478
482
/*
479
483
* go to this AppEntry FileSwapper SettingsBank folder and find all the folders
480
484
* that don't correspond to a SwapPath
481
485
*/
482
486
483
- var fileSwap = new FileSwapper ( appEntry , forPreferencesXML ) ;
487
+ var fileSwap = new FileSwapper ( appEntry , forAppEntrySaveHandler ) ;
484
488
485
489
string entryBankFolderName = fileSwap . SettingsBankFolderName ;
486
490
string pathToAppEntryBank = Path . Combine ( SwapPathFolder , entryBankFolderName ) ;
@@ -509,7 +513,7 @@ public static string[] GetOrphanedSwapPathFoldersFor(AppEntry appEntry, Preferen
509
513
return orphanedBankedFolderPaths . ToArray ( ) ;
510
514
}
511
515
512
- public static string [ ] GetOrphanedAppEntryFolders ( IEnumerable < AppEntry > appEntries , PreferencesXML forPreferencesXML )
516
+ public static string [ ] GetOrphanedAppEntryFolders ( IEnumerable < AppEntry > appEntries , AppEntrySaveHandler forAppEntrySaveHandler )
513
517
{
514
518
515
519
string [ ] bankedFolderPaths = Directory . GetDirectories ( SwapPathFolder ) ;
@@ -518,7 +522,7 @@ public static string[] GetOrphanedAppEntryFolders(IEnumerable<AppEntry> appEntri
518
522
List < string > nonOrphanedFolderPaths = new ( ) ;
519
523
foreach ( AppEntry appEntry in appEntries )
520
524
{
521
- var fileSwap = new FileSwapper ( appEntry , forPreferencesXML ) ;
525
+ var fileSwap = new FileSwapper ( appEntry , forAppEntrySaveHandler ) ;
522
526
523
527
string correspondingFolderName = fileSwap . SettingsBankFolderName ;
524
528
string correspondingFolderPath = Path . Combine ( SwapPathFolder , correspondingFolderName ) ;
@@ -535,17 +539,17 @@ from folderName in bankedFolderPaths
535
539
return orphanedFolderPaths . ToArray ( ) ;
536
540
}
537
541
538
- public static long GetOrphanedSize ( IEnumerable < AppEntry > appEntries , PreferencesXML forPreferencesXML )
542
+ public static long GetOrphanedSize ( IEnumerable < AppEntry > appEntries , AppEntrySaveHandler forAppEntrySaveHandler )
539
543
{
540
- string [ ] orphanedAppEntryFolders = GetOrphanedAppEntryFolders ( appEntries , forPreferencesXML ) ;
544
+ string [ ] orphanedAppEntryFolders = GetOrphanedAppEntryFolders ( appEntries , forAppEntrySaveHandler ) ;
541
545
542
546
List < string > orphanedSwapPathFolders = new ( ) ;
543
547
544
548
foreach ( AppEntry appEntry in appEntries )
545
549
{
546
- FileSwapper fileSwapper = new FileSwapper ( appEntry , forPreferencesXML ) ;
550
+ FileSwapper fileSwapper = new FileSwapper ( appEntry , forAppEntrySaveHandler ) ;
547
551
if ( Directory . Exists ( fileSwapper . SettingsBankFolderName ) )
548
- orphanedSwapPathFolders . AddRange ( GetOrphanedSwapPathFoldersFor ( appEntry , forPreferencesXML ) ) ;
552
+ orphanedSwapPathFolders . AddRange ( GetOrphanedSwapPathFoldersFor ( appEntry , forAppEntrySaveHandler ) ) ;
549
553
}
550
554
551
555
long totalSizeOfOrphaned = 0 ;
@@ -627,11 +631,8 @@ public static long DirSize(DirectoryInfo d)
627
631
return size ;
628
632
}
629
633
630
- public static long DirSize_Orphaned ( DirectoryInfo d , IEnumerable < AppEntry > appEntries , PreferencesXML preferencesXML )
634
+ public static long DirSize_Orphaned ( DirectoryInfo d , IEnumerable < AppEntry > appEntries , AppEntrySaveHandler forAppEntrySaveHandler )
631
635
{
632
-
633
-
634
-
635
636
636
637
long size = 0 ;
637
638
// Add file sizes.
0 commit comments