1
1
using MahApps . Metro . Controls . Dialogs ;
2
+ using Steam_Library_Manager . Definitions . Enums ;
2
3
using System ;
3
4
using System . Collections . Async ;
4
5
using System . Diagnostics ;
@@ -72,12 +73,13 @@ public override async void UpdateAppListAsync()
72
73
{
73
74
return ;
74
75
}
76
+
75
77
List . LCProgress . Report ( new List . JunkInfo
76
78
{
77
79
FSInfo = new FileInfo ( acfFile . FullName ) ,
78
- Size = acfFile . Length ,
80
+ Size = Functions . FileSystem . FormatBytes ( acfFile . Length ) ,
79
81
Library = this ,
80
- JunkReason = Functions . SLM . Translate ( nameof ( Properties . Resources . CorruptedAcfFile ) )
82
+ Tag = JunkType . CorruptedDataFile
81
83
} ) ;
82
84
83
85
return ;
@@ -95,7 +97,7 @@ await Directory.EnumerateFiles(DirectoryList["SteamApps"].FullName, "*.zip", Sea
95
97
. ParallelForEachAsync ( async archive => { await Task . Run ( ( ) => Functions . App . ReadDetailsFromZip ( archive , this ) ) . ConfigureAwait ( false ) ; } ) . ConfigureAwait ( false ) ;
96
98
97
99
DirectoryList [ "SteamBackups" ] . Refresh ( ) ;
98
- if ( Type == Enums . LibraryType . SLM && DirectoryList [ "SteamBackups" ] . Exists )
100
+ if ( Type == LibraryType . SLM && DirectoryList [ "SteamBackups" ] . Exists )
99
101
{
100
102
await DirectoryList [ "SteamBackups" ] . EnumerateFiles ( "*.sis" , SearchOption . AllDirectories ) . ParallelForEachAsync (
101
103
async skuFile =>
@@ -301,38 +303,37 @@ public override async void RemoveLibraryAsync(bool withFiles)
301
303
302
304
List . Libraries . Remove ( this ) ;
303
305
304
- if ( Type == Enums . LibraryType . Steam )
305
- {
306
- await Functions . Steam . CloseSteamAsync ( ) . ConfigureAwait ( true ) ;
306
+ if ( Type != LibraryType . Steam ) return ;
307
307
308
- // Make a KeyValue reader
309
- var keyValReader = new Framework . KeyValue ( ) ;
308
+ await Functions . Steam . CloseSteamAsync ( ) . ConfigureAwait ( true ) ;
310
309
311
- // Read vdf file
312
- keyValReader . ReadFileAsText ( Global . Steam . VdfFilePath ) ;
310
+ // Make a KeyValue reader
311
+ var keyValReader = new Framework . KeyValue ( ) ;
313
312
314
- // Remove old library
315
- keyValReader [ "Software" ] [ "Valve" ] [ "Steam" ] . Children . RemoveAll ( x => x . Value == FullPath ) ;
313
+ // Read vdf file
314
+ keyValReader . ReadFileAsText ( Global . Steam . VdfFilePath ) ;
316
315
317
- var i = 1 ;
318
- foreach ( var key in keyValReader [ "Software" ] [ "Valve" ] [ "Steam" ] . Children . FindAll ( x => x . Name . Contains ( "BaseInstallFolder" ) ) )
319
- {
320
- key . Name = $ "BaseInstallFolder_{ i } ";
321
- i ++ ;
322
- }
316
+ // Remove old library
317
+ keyValReader [ "Software" ] [ "Valve" ] [ "Steam" ] . Children . RemoveAll ( x => x . Value == FullPath ) ;
323
318
324
- // Update libraryFolders.vdf file with changes
325
- keyValReader . SaveToFile ( Global . Steam . VdfFilePath , false ) ;
319
+ var i = 1 ;
320
+ foreach ( var key in keyValReader [ "Software" ] [ "Valve" ] [ "Steam" ] . Children . FindAll ( x => x . Name . Contains ( "BaseInstallFolder" ) ) )
321
+ {
322
+ key . Name = $ "BaseInstallFolder_{ i } ";
323
+ i ++ ;
324
+ }
326
325
327
- // Since this file started to interrupt us?
328
- // No need to bother with it since config.vdf is the real deal, just remove it and Steam client will handle with some magic.
329
- if ( File . Exists ( Path . Combine ( Properties . Settings . Default . steamInstallationPath , "steamapps" , "libraryfolders.vdf" ) ) )
330
- {
331
- File . Delete ( Path . Combine ( Properties . Settings . Default . steamInstallationPath , "steamapps" , "libraryfolders.vdf" ) ) ;
332
- }
326
+ // Update libraryFolders.vdf file with changes
327
+ keyValReader . SaveToFile ( Global . Steam . VdfFilePath , false ) ;
333
328
334
- Functions . Steam . RestartSteamAsync ( ) ;
329
+ // Since this file started to interrupt us?
330
+ // No need to bother with it since config.vdf is the real deal, just remove it and Steam client will handle with some magic.
331
+ if ( File . Exists ( Path . Combine ( Properties . Settings . Default . steamInstallationPath , "steamapps" , "libraryfolders.vdf" ) ) )
332
+ {
333
+ File . Delete ( Path . Combine ( Properties . Settings . Default . steamInstallationPath , "steamapps" , "libraryfolders.vdf" ) ) ;
335
334
}
335
+
336
+ Functions . Steam . RestartSteamAsync ( ) ;
336
337
}
337
338
catch ( Exception ex )
338
339
{
@@ -364,12 +365,12 @@ public override void UpdateJunks()
364
365
var junk = new List . JunkInfo
365
366
{
366
367
FSInfo = dirInfo ,
367
- Size = Functions . FileSystem . GetDirectorySize ( dirInfo , true ) ,
368
+ Size = Functions . FileSystem . FormatBytes ( Functions . FileSystem . GetDirectorySize ( dirInfo , true ) ) ,
368
369
Library = this ,
369
- JunkReason = Functions . SLM . Translate ( nameof ( Properties . Resources . HeadlessFolderNoCorrespondingAcfFile ) )
370
+ Tag = JunkType . HeadlessFolder
370
371
} ;
371
372
372
- if ( List . LcItems . Count ( x => x . FSInfo . FullName == junk . FSInfo . FullName ) == 0 )
373
+ if ( List . JunkItems . Count ( x => x . FSInfo . FullName == junk . FSInfo . FullName ) == 0 )
373
374
{
374
375
if ( Properties . Settings . Default . IgnoredJunks != null &&
375
376
Properties . Settings . Default . IgnoredJunks . Contains ( dirInfo . FullName ) )
@@ -394,12 +395,12 @@ public override void UpdateJunks()
394
395
var junk = new List . JunkInfo
395
396
{
396
397
FSInfo = fileDetails ,
397
- Size = fileDetails . Length ,
398
+ Size = Functions . FileSystem . FormatBytes ( fileDetails . Length ) ,
398
399
Library = this ,
399
- JunkReason = Functions . SLM . Translate ( nameof ( Properties . Resources . HeadlessFileNoCorrespondingİnstallation ) )
400
+ Tag = JunkType . HeadlessWorkshopFolder
400
401
} ;
401
402
402
- if ( List . LcItems . Count ( x => x . FSInfo . FullName == junk . FSInfo . FullName ) == 0 )
403
+ if ( List . JunkItems . Count ( x => x . FSInfo . FullName == junk . FSInfo . FullName ) == 0 )
403
404
{
404
405
if ( Properties . Settings . Default . IgnoredJunks != null &&
405
406
Properties . Settings . Default . IgnoredJunks . Contains ( fileDetails . FullName ) )
@@ -417,5 +418,39 @@ public override void UpdateJunks()
417
418
Logger . Fatal ( ex ) ;
418
419
}
419
420
}
421
+
422
+ public override void UpdateDupes ( )
423
+ {
424
+ try
425
+ {
426
+ while ( IsUpdatingAppList )
427
+ {
428
+ Task . Delay ( 5000 ) ;
429
+ }
430
+
431
+ foreach ( var library in List . Libraries . Where ( x => x . Type == LibraryType . Steam && x != this ) )
432
+ {
433
+ foreach ( var targetApp in library . Apps . Where ( x => ! x . IsCompressed ) )
434
+ {
435
+ foreach ( var currentApp in Apps . Where ( x => ! x . IsCompressed && x . AppId == targetApp . AppId ) )
436
+ {
437
+ if ( List . DupeItems . Count ( x => x . App1 == targetApp || x . App2 == targetApp ) == 0 )
438
+ {
439
+ List . DupeItems . Add ( new List . DupeInfo ( )
440
+ {
441
+ App1 = currentApp ,
442
+ App2 = targetApp ,
443
+ Size = targetApp . PrettyGameSize ,
444
+ } ) ;
445
+ }
446
+ }
447
+ }
448
+ }
449
+ }
450
+ catch ( Exception ex )
451
+ {
452
+ Logger . Fatal ( ex ) ;
453
+ }
454
+ }
420
455
}
421
456
}
0 commit comments