[pr-fix][startup] config: an empty path in darner.toml means unset, not the working directory #383
Loading…
Reference in a new issue
No description provided.
Delete branch "qnjk/Darner:config-empty-path"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Contributor role (optional)
What it changes
The problem on main: the environment values are filtered so that an empty value means unset (
let env_path = |k: &str| env(k).filter(|v| !v.is_empty()).map(PathBuf::from);,crates/darner-core/src/config.rs:100) and so isphysical_pages_dirfrom the file (with a test pinning it,config.rs:352), but the other file fields are not:(
config.rs:107-109, the same at:110-112fordata_dirand:128forgame_dir). So[paths] cache_dir = ''yieldsPathBuf::from(""). The empty path is not "the default":subdir/checked_dirjoin the sub-name onto it, andPath::new("").join("shaders")is the relative pathshaders, so every cache write happens in whatever directory darner was started from. On the binary built fromf3840d7, in a folder whose wholedarner.tomlisdarner configexits withError: data_dir () must not be the cache_dir () or inside it: the cache may be deleted at any time— both are the empty path, so the guard sees one inside itself and darner refuses to start at all. With onlycache_dir = ''the same binary printscache_dir :(empty) where a run withoutdarner.tomlprintsC:\Users\<user>\AppData\Local\darner\cache, anddarner translate --warmcreatesshaders\beside the config file. The same held fordata_dir,game_dirand an empty entry intest_titles.This change filters every file path the way the environment and
physical_pages_diralready were, through onefile_pathhelper, and drops emptytest_titlesentries. A path that is not empty behaves exactly as before.How it was tested
357250a(two commits onf3840d7: the fix, and the new test bringing its own user directories so that it still holds once #315 lands — see "Checked for overlap").121ae5c) merged in, the Config::resolve hunk resolved the way its author wrote it in the thread, cargo test --locked -p darner-core --lib gives 35 passed, 0 failed (32 from this branch plus the 3 #315 adds) and cargo clippy -p darner-core --all-targets -- -D warnings is clean. The merge commit is not on this branch.config::tests::an_empty_path_in_the_file_means_unsetwas also run with only the three.or_else(|| file_path(..))changed back to.or(..): it fails there and passes with the change, so it pins the defect rather than the new code.darner.tomlprints the defaultcache_dir/data_dirunder%LOCALAPPDATA%\darnerand no error, instead of the empty paths andError: data_dir () must not be the cache_dir (). Both runs aredarner config, which needs no title and no GPU.cargo clippy --locked -p darner-core --all-targets -- -D warningspasses.physical_pages_diralready did.cargo clippy --workspace --all-targets --locked -- -D warnings: passes.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passes.cargo test --workspace --locked: not green on this machine, and not because of this change. Three pre-existing failures, each covered by an open pull request:darner-gpustands still in parallel on the test deadlock #224 describes, and serially it finishes 1772 passed and 1 failed (pipeline::make::tests::a_capped_draw_waits_once_then_drops, which passes on its own) beside the order-dependentwatch::tests::ask_once_by_res_splits_reservations_without_refusalsandtexture::ahead::tests::drain_waits_until_then_callbacks_have_runflakes that #150 is about;darner-shaderfailsemit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders, whose fixture #227 fixes. Every other crate passes.darner-core's suite is green.darner configon the built binary, which resolves the same paths a run would.test_titleswere exercised; no run was started from a folder with a realdarner.tomland an emptydata_dirto see where saves go.Checklist
darner config(empty paths become the defaults) and by a unit test that fails onmain.main.docs/asset-policy.md. (cargo xtask policy: 555 files ok.)Checked for overlap
crates/darner-core/src/config.rs(default_dir(sub)becomesdefault_dir(sub, &env)); the resolution keeps both sides, and this branchs test now injects the user directories it needs, so nothing has to change on either side when they meet — verified by merging121ae5chere (35 passed). #326 touches the same file in its unused-helper cleanup. No open or closed issue mentions an empty path indarner.toml`.The environment values are filtered so that empty means unset, and so is `physical_pages_dir` from the file, but the other file fields are not: `[paths] cache_dir = ''` became `PathBuf::from("")`. That is not "the default": `subdir`/`checked_dir` join onto it, and `Path::new("").join("shaders")` is the relative path `shaders`, so every cache write landed in whatever folder darner was started from instead of under `%LOCALAPPDATA%\darner` (it was reproduced with `darner config` and `darner translate --warm` in a scratch folder). The same held for `data_dir`, `game_dir` and an empty entry of `test_titles`. All the file paths are now filtered the way the environment and `physical_pages_dir` already were. A path that is not empty behaves as before.Heads-up on the overlap with #315 (mine), checked on Windows (Rust 1.98.1,
x86_64-pc-windows-msvc): the two pull requests are each green on their own, but they don't combine cleanly, in two ways.Text conflict in
Config::resolve(crates/darner-core/src/config.rs, thecache_dir/data_dir/physical_pages_dirlines): #315 changesdefault_dir("cache")todefault_dir("cache", &env)on the same lines where this one changes.or(file.cache_dir)to.or_else(|| file_path(file.cache_dir)).git merge-treeof121ae5cand7081f4estops there. The resolution keeps both:A test that fails once both are in. #315 makes
default_dirreadLOCALAPPDATA/XDG_CACHE_HOME/HOMEthrough the injectedenvinstead of the process environment. Soan_empty_path_in_the_file_means_unset, which resolves with|_| None, finds no user directory. With the conflict resolved as above,cargo test --locked -p darner-core --lib configgives 21 passed, 1 failed:Giving the test a
LOCALAPPDATA, as the #315 tests do, makes it 22 passed, 0 failed, and it still checks the same thing:Whichever of the two lands second needs both changes. If this one lands first, I'll rebase #315 and fix the test there.
Thanks — both points check out, and I have taken the second one off the table.
an_empty_path_in_the_file_means_unsetnow answersLOCALAPPDATA/XDG_CACHE_HOME/HOMEthrough the injected closure (357250aon this branch). That is a no-op whiledefault_dirreads the process's environment — it ignores the closure, as it still does onmain— and it is exactly what the test needs once #315'sdefault_dir(sub, &env)is in, so no test edit is left for whichever side lands second.I also ran the combination here rather than trusting the numbers.
121ae5cmerged into357250a, theConfig::resolvehunk resolved exactly as you wrote it, on Windows 11, Rust 1.98.1,x86_64-pc-windows-msvc:35 is this branch's 32 plus the 3 tests #315 adds; the merge commit itself is not pushed onto this PR. So the whole of the combination is the three-line resolution you gave — no dependency in either direction.
If you would rather land #315 first, ping me and I will rebase this branch on it and re-run the same two commands; the diff of this PR would then be only the
file_pathfiltering.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.