diff --git a/.github/workflows/dotnet-ci.yml b/.github/workflows/dotnet-ci.yml index 67d47c4..04d88a5 100644 --- a/.github/workflows/dotnet-ci.yml +++ b/.github/workflows/dotnet-ci.yml @@ -1,35 +1,36 @@ name: .NET CI on: + workflow_dispatch: push: - branches: [ master ] + branches: [master, dev] pull_request: - branches: [ master ] + branches: [master] jobs: build: runs-on: windows-latest - + env: SOLUTION: src/Playnite.Extensions.sln steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - # required for LangVersion 10 - - name: Setup .NET 6.0.x - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.x - - - name: Clear local NuGet cache (workaround for failed restores on windows-latest) - run: dotnet clean $env:SOLUTION && dotnet nuget locals all --clear - - - name: Restore dependencies - run: dotnet restore $env:SOLUTION - - - name: Build - run: dotnet build $env:SOLUTION --no-restore + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + # required for LangVersion 10 + - name: Setup .NET 6.0.x + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.x + + - name: Clear local NuGet cache (workaround for failed restores on windows-latest) + run: dotnet clean $env:SOLUTION && dotnet nuget locals all --clear + + - name: Restore dependencies + run: dotnet restore $env:SOLUTION + + - name: Build + run: dotnet build $env:SOLUTION --no-restore diff --git a/.gitignore b/.gitignore index cf89c9b..bbdf7bb 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ # Mono auto generated files mono_crash.* +.mono/ # Build results [Dd]ebug/ diff --git a/src/GameManagement/GameManagementPlugin.cs b/src/GameManagement/GameManagementPlugin.cs index 2a1db68..5538ff6 100644 --- a/src/GameManagement/GameManagementPlugin.cs +++ b/src/GameManagement/GameManagementPlugin.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -115,9 +115,9 @@ private List UninstallGames(GameMenuItemActionArgs args) _logger.LogDebug("Removing {Directory}", game.InstallDirectory); Directory.Delete(game.InstallDirectory, true); } - catch (IOException) + catch (IOException ex) { - _logger.LogError("The directory {Directory} could not be deleted.", game.InstallDirectory); + _logger.LogError("The directory {Directory} could not be deleted. {ex}", game.InstallDirectory, ex); } game.IsInstalled = false; actuallyUninstalledGames.Add(game); @@ -178,4 +178,18 @@ public override IEnumerable GetSidebarItems() Visible = true, }; } + + public override IEnumerable GetMainMenuItems(GetMainMenuItemsArgs args) + { + yield return new MainMenuItem + { + Description = "Remove unknown games.", + Action = (_) => RemoveUnknownGamesAction(), + }; + } + private void RemoveUnknownGamesAction() + { + return; + } + } diff --git a/src/GameManagement/StorageInfo.cs b/src/GameManagement/StorageInfo.cs index bbeccd6..a28f3ea 100644 --- a/src/GameManagement/StorageInfo.cs +++ b/src/GameManagement/StorageInfo.cs @@ -14,7 +14,6 @@ namespace GameManagement; public class StorageInfo { private readonly IPlayniteAPI _playniteAPI; - public List Games { get; set; } = new(); public string TotalSize => $"Total Size: {Games.Sum(x => x.SizeOnDisk).ToFileSizeString()}"; @@ -63,6 +62,7 @@ private static long GetDirectorySize(string path) private static bool GameHasInstallDirectory(Game game) { + Console.WriteLine("Checking {Directory}", game.InstallDirectory); return !string.IsNullOrWhiteSpace(game.InstallDirectory) && Directory.Exists(game.InstallDirectory); } @@ -72,9 +72,9 @@ public void UpdateStorageInfoForAllNewGames() .Where(dbGame => !Games.Any(savedGame => savedGame.GameId.Equals(dbGame.Id))) .Where(GameHasInstallDirectory) .Select(x => new TempStorage(x, new GameStorage(_playniteAPI) - { - GameId = x.Id - })).ToArray(); + { + GameId = x.Id + })).ToArray(); ParallelHelper.ForEach(games); @@ -130,5 +130,5 @@ public GameStorage(IPlayniteAPI playniteAPI) [DontSerialize] public string FileSizeString => SizeOnDisk.ToFileSizeString(); - [DontSerialize] public string GameName => PlayniteAPI?.Database.Games.First(x => x.Id.Equals(GameId)).Name ?? string.Empty; + [DontSerialize] public string GameName => PlayniteAPI?.Database.Games.First(x => x.Id.Equals(GameId)).Name ?? "Unknown Game"; }