Timberborn-Modding-Central / ModManager

6 stars 6 forks source link

Upgrading a mod does not delete files that no longer exist #64

Open normanr opened 15 hours ago

normanr commented 15 hours ago

When upgrade a mod, if files have been renamed or deleted, then the old version of the file is not removed.

When the code in ModManager/ModSystem/ModExtractor.cs was changed to support update 6 the folder name was changed as such:

-var modFolderName = $"{modInfo.NameId}_{modInfo.Id}_{modInfo.Modfile.Version}";
+var modFolderName = $"{modInfo.NameId}_{modInfo.Id}";

but ClearOldModFiles only works if modFolderName is different, so without the mod version suffix it won't remove old files.

ref: https://github.com/TobbyTheBobby/ModManager/commit/6dc62d16e4de214bd4971feb34384c08e51cf8e9#diff-41f14a3c19303c9a2648518d483e19c1d9d0e259678e2df4340c7e62c08d621dR24

normanr commented 15 hours ago

Discord links where this bug is discussed:

normanr commented 15 hours ago

The issue with deleting all old files is that there might be some user customization (e.g. user config file, or custom image or sound assets). So maybe a list of installed files could be added to mod_manager_manifest.json, so that they can be tracked and deleted when next upgrade happens. (Mods with custom configs would need to ship "example" configs, or create them dynamically, so that they're not tracked to be deleted).