Skip to content

Only hard link existing files if file sizes match - #4453

Merged
HebaruSan merged 6 commits into
KSP-CKAN:masterfrom
HebaruSan:fix/dedup-manual-overwrites
Oct 22, 2025
Merged

HebaruSan merged 6 commits into
KSP-CKAN:masterfrom
HebaruSan:fix/dedup-manual-overwrites

Conversation

@HebaruSan

@HebaruSan HebaruSan commented Oct 22, 2025 •

Copy link
Copy Markdown
Member

Problems

  • If a user (typically a mod author) installs a mod with CKAN and then overwrites some of its large (>128KiB) files, then installs the same version of the same mod in another game instance, CKAN (dev build only) will deduplicate that file by creating a hard link to the original, which has the effect of unintentionally propagating the user's manual changes into another game instance.
    Both @linuxgurugamer and @JonnyOThan have reported this.
  • If both CKAN/GUIConfig.json and CKAN/GUIConfig.xml are missing, a FileNotFound exception is thrown when opening the game instance (also dev build only).
    Reported by @Clayell on Discord.

Causes

  • InstalledFilesDeduplicator uses the mod identifier, version, and file relative path to uniquely identify files that might be duplicates. Since overwriting a file doesn't change any of these, an overwritten file is considered the same as the original and can be hard linked instead of extracted when installing the same file in another instance.
  • GUIConfiguration.LoadXML handles exceptions for parsing the file, but not for when it doesn't exist.

Changes

  • Now InstalledFilesDeduplicator uses the mod identifier, version, file relative path, and file size to uniquely identify files that might be duplicates. This way, if the file size doesn't match what's in the original ZIP, we conclude that it has been overwritten and won't create a hard link to it.
    File size is not a perfect way to detect changed files, but it is extremely low-cost to calculate compared to hashing, and different files are unlikely to have the same size when they're generaed by a paint program or a compiler.
    Fixes Manual overwrites of hard linkable files installed by CKAN can create hard links to the overwritten files #4451.
  • Now if both CKAN/GUIConfig.json and CKAN/GUIConfig.xml are missing, GUIConfiguration.LoadXML catches the exception and returns null so we can fall back to a new config object.

@HebaruSan HebaruSan added Bug Something is not working as intended Enhancement New features or functionality GUI Issues affecting the interactive GUI Core (ckan.dll) Issues affecting the core part of CKAN Tests Issues affecting the internal tests labels Oct 22, 2025
@coveralls

This comment was marked as off-topic.

@HebaruSan
HebaruSan merged commit 1d05e91 into KSP-CKAN:master Oct 22, 2025
6 checks passed
@HebaruSan
HebaruSan deleted the fix/dedup-manual-overwrites branch October 22, 2025 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working as intended Core (ckan.dll) Issues affecting the core part of CKAN Enhancement New features or functionality GUI Issues affecting the interactive GUI Tests Issues affecting the internal tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Manual overwrites of hard linkable files installed by CKAN can create hard links to the overwritten files

2 participants