config: a relative cache_dir or data_dir is pinned at load #603

Open
qnjk wants to merge 1 commit from qnjk/Darner:config-absolute-paths into Main
Contributor

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: Config::resolve keeps cache_dir and data_dir exactly as written, so a relative [paths] cache_dir = "cache" stays relative — and the title changes the process working directory (SetCurrentDirectory). Everything derived from those paths then lands somewhere else than the configuration said. prepare_page_files already resolves its own path with std::path::absolute for exactly that reason (config.rs:158-162); the two directories did not.

  • This change resolves both once, at Config::resolve, through one absolute_dir helper, and leaves every other path rule (empty means unset, the outside-the-repo check) untouched. A path that is already absolute is unchanged.

How it was tested

  • Tested revision: b4b7f6f (one commit on c8258f9).
  • Commands and results:
    • cargo test --locked -p darner-core --lib — 51 passed, 0 failed.
    • New test config::tests::relative_configured_dirs_are_made_absolute_at_load resolves [paths] cache_dir = "cache" and asserts the result is absolute, and that it does not move when the process working directory changes.
    • Fail-before, by replacing absolute_dir with the old pass-through and keeping the test:
      relative_configured_dirs_are_made_absolute_at_load ... FAILED
      Config { game_dir: None, physical_pages_dir: None, cache_dir: "cache", data_dir: "data", ... }
      
    • cargo clippy --locked -p darner-core --all-targets -- -D warnings passes.
  • Changes a default: no. An absolute path is untouched; a relative one is resolved once against the working directory at load, which is the directory it already meant.
  • A/B result: not applicable — no default changes and no speed claim.
  • Gates run on that revision:
    • Gate 1, cargo clippy --workspace --all-targets --locked -- -D warnings: passes.
    • Gate 2, cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passes.
    • Gate 3, cargo test --workspace --locked: not run to completion here; the pre-existing darner-gpu test deadlock (#224) and darner-shader waterfall fixture failure (#227) make the whole-workspace run non-green on this machine. darner-core's suite is green.
  • Gameplay, when relevant: no gameplay run. The change cannot alter the title; it pins where darner's own files go.
  • Shader wave sizes tested, when relevant: not applicable.
  • Hardware dependence: none.
  • Coverage gaps: game_dir and test_titles are not resolved (they are read, not written, and the title never changes directory before them in today's flow); darner config still prints the resolved paths, but a run from a changed working directory was not done end to end.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
    • Not run in gameplay: the change is about where darner writes, not what the title does. The evidence is the test, which fails on main.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md (cargo xtask policy: 576 files ok).
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #326 changes crates/darner-core/src/config.rs (unused-helper cleanup). No open or closed issue mentions a relative cache_dir.
  • Replaces or overlaps: none found
## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: `Config::resolve` keeps `cache_dir` and `data_dir` exactly as written, so a relative `[paths] cache_dir = "cache"` stays relative — and the title changes the process working directory (`SetCurrentDirectory`). Everything derived from those paths then lands somewhere else than the configuration said. `prepare_page_files` already resolves its own path with `std::path::absolute` for exactly that reason (`config.rs:158-162`); the two directories did not. - This change resolves both once, at `Config::resolve`, through one `absolute_dir` helper, and leaves every other path rule (empty means unset, the outside-the-repo check) untouched. A path that is already absolute is unchanged. ## How it was tested - Tested revision: `b4b7f6f` (one commit on `c8258f9`). - Commands and results: - `cargo test --locked -p darner-core --lib` — 51 passed, 0 failed. - New test `config::tests::relative_configured_dirs_are_made_absolute_at_load` resolves `[paths] cache_dir = "cache"` and asserts the result is absolute, and that it does not move when the process working directory changes. - Fail-before, by replacing `absolute_dir` with the old pass-through and keeping the test: ``` relative_configured_dirs_are_made_absolute_at_load ... FAILED Config { game_dir: None, physical_pages_dir: None, cache_dir: "cache", data_dir: "data", ... } ``` - `cargo clippy --locked -p darner-core --all-targets -- -D warnings` passes. - Changes a default: no. An absolute path is untouched; a relative one is resolved once against the working directory at load, which is the directory it already meant. - A/B result: not applicable — no default changes and no speed claim. - Gates run on that revision: - Gate 1, `cargo clippy --workspace --all-targets --locked -- -D warnings`: passes. - Gate 2, `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passes. - Gate 3, `cargo test --workspace --locked`: not run to completion here; the pre-existing `darner-gpu` test deadlock (#224) and `darner-shader` waterfall fixture failure (#227) make the whole-workspace run non-green on this machine. `darner-core`'s suite is green. - Gameplay, when relevant: no gameplay run. The change cannot alter the title; it pins where darner's own files go. - Shader wave sizes tested, when relevant: not applicable. - Hardware dependence: none. - Coverage gaps: `game_dir` and `test_titles` are not resolved (they are read, not written, and the title never changes directory before them in today's flow); `darner config` still prints the resolved paths, but a run from a changed working directory was not done end to end. ## Checklist - [x] I ran this change in the game, or say below why it can't be (docs, tests only). - Not run in gameplay: the change is about where darner writes, not what the title does. The evidence is the test, which fails on `main`. - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md` (`cargo xtask policy`: 576 files ok). - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #326 changes `crates/darner-core/src/config.rs` (unused-helper cleanup). No open or closed issue mentions a relative `cache_dir`. - Replaces or overlaps: none found
`Config::resolve` stored `[paths] cache_dir`/`data_dir` exactly as written and
every later use joined a sub-name onto that relative path. The process working
directory is not stable after startup: the title's `SetCurrentDirectoryW` is
forwarded to the host, and two call sites already absolutise their own
directories for that reason (`prepare_page_files` on the page-file pool, the
GPU pipeline cache). With `cache_dir = 'cache'` the shader cache and the saves
therefore followed whichever folder the title selected last, outside the cache
root that the clear and move logic work on.

Resolve both once in `resolve`, while the working directory is still darner's
own, and let the data/cache overlap guard compare the resolved paths. An
already-absolute path is kept as it is, so only relative configuration changes.

The test re-executes the test binary with a working directory of its own, as
the cache-folder-pick test does, so that it can change the process working
directory without disturbing the other config tests; it pins the resolved
paths to the directory they were resolved in.
TrustNo1 changed title from [pr-fix][startup] config: a relative cache_dir or data_dir is pinned at load to config: a relative cache_dir or data_dir is pinned at load 2026-12-06 03:26:26 +00:00
Owner

Test needed — commit b4b7f6fb; what to check:

  • The problem on main: Config::resolve keeps cache_dir and data_dir exactly as written, so a relative [paths] cache_dir = "cache" stays relative — and the title changes the process working directory (SetCurrentDirectory). Everything derived from those paths then lands somewhere else than the configuration said. prepare_page_files already resolves its own path with std::path::absolute for exactly that reason (config.rs:158-162); the two directories did not.

  • This change resolves both once, at Config::resolve, through one absolute_dir helper, and leaves every other path rule (empty means unset, the outside-the-repo check) untouched. A path that is already absolute is unchanged.

Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.

Reply testing to take this run; it's free again after 24 h with no results.

**Test needed** — commit `b4b7f6fb`; what to check: - The problem on main: `Config::resolve` keeps `cache_dir` and `data_dir` exactly as written, so a relative `[paths] cache_dir = "cache"` stays relative — and the title changes the process working directory (`SetCurrentDirectory`). Everything derived from those paths then lands somewhere else than the configuration said. `prepare_page_files` already resolves its own path with `std::path::absolute` for exactly that reason (`config.rs:158-162`); the two directories did not. - This change resolves both once, at `Config::resolve`, through one `absolute_dir` helper, and leaves every other path rule (empty means unset, the outside-the-repo check) untouched. A path that is already absolute is unchanged. Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture. Reply `testing` to take this run; it's free again after 24 h with no results.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'config-absolute-paths:qnjk-config-absolute-paths'
git switch 'qnjk-config-absolute-paths'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'Main'
git merge --no-ff 'qnjk-config-absolute-paths'
git switch 'qnjk-config-absolute-paths'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'qnjk-config-absolute-paths'
git switch 'qnjk-config-absolute-paths'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'qnjk-config-absolute-paths'
git switch 'Main'
git merge --squash 'qnjk-config-absolute-paths'
git switch 'Main'
git merge --ff-only 'qnjk-config-absolute-paths'
git switch 'Main'
git merge 'qnjk-config-absolute-paths'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!603
No description provided.