From: <sv...@op...> - 2024-08-04 21:53:09
|
Author: sagamusix Date: Sun Aug 4 23:52:56 2024 New Revision: 21325 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21325 Log: [Mod/Fix] In the plugin cache, encode the relative path instead of absolute path in CRC32 in portable mode. That way, the cache remains valid when the portable installation is moved to a different location and doesn't have to re-scan plugins every time. Modified: trunk/OpenMPT/soundlib/plugins/PluginManager.cpp Modified: trunk/OpenMPT/soundlib/plugins/PluginManager.cpp ============================================================================== --- trunk/OpenMPT/soundlib/plugins/PluginManager.cpp Sun Aug 4 10:38:24 2024 (r21324) +++ trunk/OpenMPT/soundlib/plugins/PluginManager.cpp Sun Aug 4 23:52:56 2024 (r21325) @@ -237,17 +237,18 @@ { SettingsContainer &cacheFile = theApp.GetPluginCache(); - const std::string crcName = dllPath.ToUTF8(); + mpt::ustring pathStr; + if(theApp.IsPortableMode()) + pathStr = theApp.PathAbsoluteToInstallRelative(dllPath).ToUnicode(); + else + pathStr = dllPath.ToUnicode(); + + // CRC is used to distinguish plugins sharing the same IDs + const std::string crcName = mpt::ToCharset(mpt::Charset::UTF8, pathStr); const mpt::crc32 crc(crcName); const mpt::ustring IDs = mpt::ufmt::HEX0<8>(static_cast<uint32>(pluginId1)) + mpt::ufmt::HEX0<8>(static_cast<uint32>(pluginId2)) + mpt::ufmt::HEX0<8>(crc.result()); - mpt::PathString writePath = dllPath; - if(theApp.IsPortableMode()) - { - writePath = theApp.PathAbsoluteToInstallRelative(writePath); - } - - cacheFile.Write<mpt::ustring>(cacheSection, writePath.ToUnicode(), IDs); + cacheFile.Write<mpt::ustring>(cacheSection, pathStr, IDs); cacheFile.Write<CString>(cacheSection, IDs + U_(".Vendor"), vendor); cacheFile.Write<int32>(cacheSection, IDs + U_(".Flags"), EncodeCacheFlags()); } |