From 13bc113a6ca4aac426096b47999104f347af3297 Mon Sep 17 00:00:00 2001 From: Lauriethefish Date: Wed, 25 Oct 2023 16:36:22 +0100 Subject: [PATCH] Check mods status post patching --- QuestPatcher.Core/Modding/ConfigModProvider.cs | 2 +- QuestPatcher.Core/Modding/IModProvider.cs | 2 +- QuestPatcher.Core/Modding/ModManager.cs | 8 +++++++- QuestPatcher.Core/Modding/QModProvider.cs | 2 +- QuestPatcher.Core/Patching/PatchingManager.cs | 2 ++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/QuestPatcher.Core/Modding/ConfigModProvider.cs b/QuestPatcher.Core/Modding/ConfigModProvider.cs index b6c15452..6e3e2bb4 100644 --- a/QuestPatcher.Core/Modding/ConfigModProvider.cs +++ b/QuestPatcher.Core/Modding/ConfigModProvider.cs @@ -13,7 +13,7 @@ public abstract class ConfigModProvider : JsonConverter, IModProvider public abstract string FileExtension { get; } public abstract Task LoadFromFile(string modPath); public abstract Task DeleteMod(IMod mod); - public abstract Task LoadMods(); + public abstract Task LoadModsStatus(); public abstract void ClearMods(); public abstract Task LoadLegacyMods(); } diff --git a/QuestPatcher.Core/Modding/IModProvider.cs b/QuestPatcher.Core/Modding/IModProvider.cs index 9b997771..7882f769 100644 --- a/QuestPatcher.Core/Modding/IModProvider.cs +++ b/QuestPatcher.Core/Modding/IModProvider.cs @@ -29,7 +29,7 @@ public interface IModProvider /// Loads the mods from the quest. /// /// Task completing when all mods are loaded - Task LoadMods(); + Task LoadModsStatus(); /// /// Clears currently loaded mods diff --git a/QuestPatcher.Core/Modding/ModManager.cs b/QuestPatcher.Core/Modding/ModManager.cs index 7fe3f385..187e34be 100644 --- a/QuestPatcher.Core/Modding/ModManager.cs +++ b/QuestPatcher.Core/Modding/ModManager.cs @@ -180,9 +180,15 @@ public async Task LoadModsForCurrentApp() await SaveMods(); } + await UpdateModsStatus(); + } + + public async Task UpdateModsStatus() + { + Log.Information("Checking if mods are installed"); foreach (IModProvider provider in _modProviders.Values) { - await provider.LoadMods(); + await provider.LoadModsStatus(); } } diff --git a/QuestPatcher.Core/Modding/QModProvider.cs b/QuestPatcher.Core/Modding/QModProvider.cs index f83c91f2..ac3f371f 100644 --- a/QuestPatcher.Core/Modding/QModProvider.cs +++ b/QuestPatcher.Core/Modding/QModProvider.cs @@ -243,7 +243,7 @@ public override void Write(Utf8JsonWriter writer, IMod value, JsonSerializerOpti JsonSerializer.Serialize(writer, AssertQMod(value).Manifest, options); } - public override async Task LoadMods() + public override async Task LoadModsStatus() { List modFiles = await _debugBridge.ListDirectoryFiles(_modManager.ModsPath, true); List libFiles = await _debugBridge.ListDirectoryFiles(_modManager.LibsPath, true); diff --git a/QuestPatcher.Core/Patching/PatchingManager.cs b/QuestPatcher.Core/Patching/PatchingManager.cs index 621eb91c..a76aec0c 100644 --- a/QuestPatcher.Core/Patching/PatchingManager.cs +++ b/QuestPatcher.Core/Patching/PatchingManager.cs @@ -649,6 +649,8 @@ public async Task PatchApp() // Recreate the mod directories as they will not be present after the uninstall/backup restore await _modManager.CreateModDirectories(); + // When repatching, certain mods may have been deleted when the app was uninstalled, so we will check for this + await _modManager.UpdateModsStatus(); await _installManager.NewApkInstalled(_patchedApkPath);