Skip to content

Try to stop users from cloning instances into themselves#4556

Merged
HebaruSan merged 1 commit into
KSP-CKAN:masterfrom
HebaruSan:feature/check-clone-into-self
Apr 12, 2026
Merged

Try to stop users from cloning instances into themselves#4556
HebaruSan merged 1 commit into
KSP-CKAN:masterfrom
HebaruSan:feature/check-clone-into-self

Conversation

@HebaruSan
Copy link
Copy Markdown
Member

@HebaruSan HebaruSan commented Apr 12, 2026

Motivation

If a user clones a game instance into a subfolder of itself, the copy goes on forever and eventually fills the disk if not stopped.

Changes

Now when you clone an instance, we check whether any of the parent folders of the destination are the same as the source, and if so we emit an error and abort the clone.
A test is included to exercise this.

Fixes #4520.

Known limitations

Note that catching all ways to try to copy a directory into itself is a well-known impossible task, because different paths can point to the same location in obfuscated ways:

  • Make a junction / symbolic link to the game instance, then clone from the original folder into the symbolic link
  • Mount a network share at one drive letter and a subfolder of it at another drive letter, then clone from one drive to the other
  • And so on for any OS capability to assign arbitrary names to paths

While we can't detect everything, catching the very simplest case where everything is a normal directory is still easy enough to be worth it.

@HebaruSan HebaruSan added Enhancement New features or functionality Easy This is easy to fix Core (ckan.dll) Issues affecting the core part of CKAN labels Apr 12, 2026
@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 24295459733

Coverage increased (+0.04%) to 85.543%

Details

  • Coverage increased (+0.04%) from the base build.
  • Patch coverage: 6 of 6 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 14223
Covered Lines: 12013
Line Coverage: 84.46%
Relevant Branches: 2164
Covered Branches: 2005
Branch Coverage: 92.65%
Branches in Coverage %: Yes
Coverage Strength: 1.76 hits per line

💛 - Coveralls

@HebaruSan HebaruSan merged commit 51d3117 into KSP-CKAN:master Apr 12, 2026
12 checks passed
@HebaruSan HebaruSan deleted the feature/check-clone-into-self branch April 12, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Core (ckan.dll) Issues affecting the core part of CKAN Easy This is easy to fix Enhancement New features or functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: CKAN copies files infinitely if clone target folder is subdirectory of source folder

2 participants