#21 — Feature: XDG config path resolution with CWD fallback
What to build
Build the path resolution engine and wire it into the config loader. A new internal function resolves a filename by checking ~/.config/librofm-downloader/ (XDG) first, then falling back to the current working directory. The XDG parent directory is auto-created on demand with mkdir(parents=True, exist_ok=True). Returns the resolved Path if found, None if absent from both locations.
Wire this resolver into load_config() so that passing None for either path triggers search. When config.yaml is missing everywhere: non-fatal — return a fully-defaulted Config instance and raise no exception. When secrets.yaml is missing everywhere: fatal — raise a domain error (ConfigError subclass) with a message listing every path searched in order. All raw FileNotFoundError / OSError from file I/O are caught internally and converted to domain errors — no OS exceptions leak to callers.
Acceptance criteria
_resolve_config_file(filename) exists, searches XDG then CWD, returns Path | None
XDG directory ~/.config/librofm-downloader/ is auto-created when resolution runs
load_config(None, None) with only secrets present → returns Config with built-in defaults for format/output_dir/extras/covers
load_config(explicit_path, None) with explicit config path → skips search for config, still searches for secrets if None
Missing config.yaml always produces detectable signal (exception or sentinel) so CLI can print "using defaults" message
All existing tests pass unchanged (they pass explicit fixture paths)
New tests cover: XDG-only, CWD-only, both present (XDG wins), neither present, auto-creation of dir, explicit path bypasses search
Blocked by
None - can start immediately
## Parent
#21 — Feature: XDG config path resolution with CWD fallback
## What to build
Build the path resolution engine and wire it into the config loader. A new internal function resolves a filename by checking `~/.config/librofm-downloader/` (XDG) first, then falling back to the current working directory. The XDG parent directory is auto-created on demand with `mkdir(parents=True, exist_ok=True)`. Returns the resolved `Path` if found, `None` if absent from both locations.
Wire this resolver into `load_config()` so that passing `None` for either path triggers search. When `config.yaml` is missing everywhere: non-fatal — return a fully-defaulted `Config` instance and raise no exception. When `secrets.yaml` is missing everywhere: fatal — raise a domain error (`ConfigError` subclass) with a message listing every path searched in order. All raw `FileNotFoundError` / `OSError` from file I/O are caught internally and converted to domain errors — no OS exceptions leak to callers.
## Acceptance criteria
- [ ] `_resolve_config_file(filename)` exists, searches XDG then CWD, returns `Path | None`
- [ ] XDG directory `~/.config/librofm-downloader/` is auto-created when resolution runs
- [ ] `load_config(None, None)` with only secrets present → returns Config with built-in defaults for format/output_dir/extras/covers
- [ ] `load_config(None, None)` with neither file → raises domain error listing searched paths (not FileNotFoundError)
- [ ] `load_config(explicit_path, None)` with explicit config path → skips search for config, still searches for secrets if None
- [ ] Missing config.yaml always produces detectable signal (exception or sentinel) so CLI can print "using defaults" message
- [ ] All existing tests pass unchanged (they pass explicit fixture paths)
- [ ] New tests cover: XDG-only, CWD-only, both present (XDG wins), neither present, auto-creation of dir, explicit path bypasses search
## Blocked by
None - can start immediately
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Parent
#21 — Feature: XDG config path resolution with CWD fallback
What to build
Build the path resolution engine and wire it into the config loader. A new internal function resolves a filename by checking
~/.config/librofm-downloader/(XDG) first, then falling back to the current working directory. The XDG parent directory is auto-created on demand withmkdir(parents=True, exist_ok=True). Returns the resolvedPathif found,Noneif absent from both locations.Wire this resolver into
load_config()so that passingNonefor either path triggers search. Whenconfig.yamlis missing everywhere: non-fatal — return a fully-defaultedConfiginstance and raise no exception. Whensecrets.yamlis missing everywhere: fatal — raise a domain error (ConfigErrorsubclass) with a message listing every path searched in order. All rawFileNotFoundError/OSErrorfrom file I/O are caught internally and converted to domain errors — no OS exceptions leak to callers.Acceptance criteria
_resolve_config_file(filename)exists, searches XDG then CWD, returnsPath | None~/.config/librofm-downloader/is auto-created when resolution runsload_config(None, None)with only secrets present → returns Config with built-in defaults for format/output_dir/extras/coversload_config(None, None)with neither file → raises domain error listing searched paths (not FileNotFoundError)load_config(explicit_path, None)with explicit config path → skips search for config, still searches for secrets if NoneBlocked by
None - can start immediately
Implemented in commit
3ba9f25. XDG→CWD path resolution, missing-config notice, OS→domain error wrapping. 9 new tests, 181 total pass. All 8 AC met.