From c1342bd4cd6b75b24d11275bdd73ebf893f916ea Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 4 May 2022 20:35:08 -0400 Subject: disable case-insensitive paths by default pending performance rework --- src/SMAPI/Framework/ModLoading/ModResolver.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/SMAPI/Framework/ModLoading') diff --git a/src/SMAPI/Framework/ModLoading/ModResolver.cs b/src/SMAPI/Framework/ModLoading/ModResolver.cs index 74e7cb32..1b1fa04e 100644 --- a/src/SMAPI/Framework/ModLoading/ModResolver.cs +++ b/src/SMAPI/Framework/ModLoading/ModResolver.cs @@ -9,6 +9,7 @@ using StardewModdingAPI.Toolkit.Framework.ModScanning; using StardewModdingAPI.Toolkit.Framework.UpdateData; using StardewModdingAPI.Toolkit.Serialization.Models; using StardewModdingAPI.Toolkit.Utilities; +using StardewModdingAPI.Toolkit.Utilities.PathLookups; namespace StardewModdingAPI.Framework.ModLoading { @@ -22,10 +23,11 @@ namespace StardewModdingAPI.Framework.ModLoading /// The mod toolkit. /// The root path to search for mods. /// Handles access to SMAPI's internal mod metadata list. + /// Whether to match file paths case-insensitively, even on Linux. /// Returns the manifests by relative folder. - public IEnumerable ReadManifests(ModToolkit toolkit, string rootPath, ModDatabase modDatabase) + public IEnumerable ReadManifests(ModToolkit toolkit, string rootPath, ModDatabase modDatabase, bool useCaseInsensitiveFilePaths) { - foreach (ModFolder folder in toolkit.GetModFolders(rootPath)) + foreach (ModFolder folder in toolkit.GetModFolders(rootPath, useCaseInsensitiveFilePaths)) { Manifest? manifest = folder.Manifest; @@ -56,10 +58,11 @@ namespace StardewModdingAPI.Framework.ModLoading /// The mod manifests to validate. /// The current SMAPI version. /// Get an update URL for an update key (if valid). + /// Get a file path lookup for the given directory. /// Whether to validate that files referenced in the manifest (like ) exist on disk. This can be disabled to only validate the manifest itself. [SuppressMessage("ReSharper", "ConstantConditionalAccessQualifier", Justification = "Manifest values may be null before they're validated.")] [SuppressMessage("ReSharper", "ConditionIsAlwaysTrueOrFalse", Justification = "Manifest values may be null before they're validated.")] - public void ValidateManifests(IEnumerable mods, ISemanticVersion apiVersion, Func getUpdateUrl, bool validateFilesExist = true) + public void ValidateManifests(IEnumerable mods, ISemanticVersion apiVersion, Func getUpdateUrl, Func getFilePathLookup, bool validateFilesExist = true) { mods = mods.ToArray(); @@ -144,7 +147,8 @@ namespace StardewModdingAPI.Framework.ModLoading // file doesn't exist if (validateFilesExist) { - string fileName = CaseInsensitivePathLookup.GetCachedFor(mod.DirectoryPath).GetFilePath(mod.Manifest.EntryDll!); + IFilePathLookup pathLookup = getFilePathLookup(mod.DirectoryPath); + string fileName = pathLookup.GetFilePath(mod.Manifest.EntryDll!); if (!File.Exists(Path.Combine(mod.DirectoryPath, fileName))) { mod.SetStatus(ModMetadataStatus.Failed, ModFailReason.InvalidManifest, $"its DLL '{mod.Manifest.EntryDll}' doesn't exist."); -- cgit