Refine macOS/LogAlias platform tuning, fix a real WithRoot bug found on Windows
Platform tuning:
- macOS Desktop's RuntimeDir() now prefers $TMPDIR (the OS-managed,
per-user ephemeral directory NSTemporaryDirectory() returns) over
the previous ~/Library/Application Support/<App>/Runtime placeholder.
- Resolver.EnsureLogAlias() creates the optional LogAliasDir() symlink
to LogDir(), idempotently, leaving any pre-existing entry alone.
Verified the SHGetKnownFolderPath fallback (knownfolders_windows.go)
on a real Windows host for the first time: with APPDATA/LOCALAPPDATA/
PROGRAMDATA all unset, it correctly resolves the real known folders.
go vet's one unsafeptr finding there is a documented, permanent,
unavoidable characteristic of this raw-syscall pattern, not a bug.
That same real-Windows run surfaced a genuine, previously-invisible
bug: WithRoot assumed root's own address family always matched the
*simulated* platform's, which silently broke (mixed separators, or an
outright invalid mid-path drive letter) whenever the real host's
native family differed from what WithPlatform was simulating -- e.g.
WithPlatform("linux") with WithRoot(t.TempDir()) on a real Windows
host. This was invisible on macOS/Linux, where t.TempDir() happens to
already share the simulated Unix family.
Fixed applyRoot (now applyRootRebase) to decompose the resolved path
into segments and re-join them onto root using root's own family,
inferred from its content like JoinDirFile already does, not from the
simulated platform. Two call sites chaining onto an already-rooted
value (logDirUnix, darwin.go's State/Runtime fallback) switched from a
hardcoded unixJoin to JoinDirFile for the same reason. core/config's
working-directory layer had the identical bug one level up; fixed via
a new paths.JoinDirFileFamily.
TODO.md/ARCHITECTURE.md/README.md updated accordingly; core/TODO.md's
remaining items are now all explicitly out-of-scope or deliberately
deprioritized, not open work.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e6b5324ad3
commit
da2ec85381
13 files changed
+515
-70
No files matched your search
+19
-2
@@ -80,7 +80,11 @@ func (r *Resolver) darwinDesktopStateDir() (value, error) {
|
||||
if err != nil {
|
||||
return value{}, err
|
||||
}
|
||||
return value{path: unixJoin(app.path, "State"), source: app.source}, nil
|
||||
// app.path already applied the root (see applyRootRebase), which can
|
||||
// be a different address family than this simulated platform -- use
|
||||
// JoinDirFile, not unixJoin, so the "State" suffix lands in whichever
|
||||
// family app.path actually ended up in.
|
||||
return value{path: JoinDirFile(app.path, "State"), source: app.source}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) darwinDesktopCacheDir() (value, error) {
|
||||
@@ -113,15 +117,28 @@ func (r *Resolver) darwinDesktopLogDir() (value, error) {
|
||||
return value{path: r.applyRoot(unixJoin(darwinLogsBase(r.app.Scope, home), r.app.Name)), source: source}, nil
|
||||
}
|
||||
|
||||
// darwinDesktopRuntimeDir prefers $TMPDIR -- the per-user, securely
|
||||
// permissioned, OS-managed ephemeral directory macOS itself hands every
|
||||
// process (confstr(_CS_DARWIN_USER_TEMP_DIR), what NSTemporaryDirectory()
|
||||
// returns), the closest real native equivalent to XDG_RUNTIME_DIR's
|
||||
// role. It falls back to the previous Application Support-based location
|
||||
// only when TMPDIR is unset in the resolved environment (e.g. a
|
||||
// simulated/test environment that never set it) -- see AGENTS.md TODO
|
||||
// history: this was a placeholder before TMPDIR was wired in here.
|
||||
func (r *Resolver) darwinDesktopRuntimeDir() (value, error) {
|
||||
if v, ok := r.overrideValue(RuntimePath); ok {
|
||||
return value{path: r.applyRoot(v.path), source: v.source}, nil
|
||||
}
|
||||
if tmpdir, ok := lookup(r.env, "TMPDIR"); ok {
|
||||
return value{path: r.applyRoot(unixJoin(tmpdir, r.app.Name)), source: MacOSNative}, nil
|
||||
}
|
||||
app, err := r.darwinDesktopAppDir()
|
||||
if err != nil {
|
||||
return value{}, err
|
||||
}
|
||||
return value{path: unixJoin(app.path, "Runtime"), source: app.source}, nil
|
||||
// See darwinDesktopStateDir: app.path is already rooted and may be in
|
||||
// either address family, so JoinDirFile picks the right one.
|
||||
return value{path: JoinDirFile(app.path, "Runtime"), source: app.source}, nil
|
||||
}
|
||||
|
||||
// darwinDesktopBinDir has no native GUI-app convention; it reuses the
|
||||
|
||||
Reference in new issue
Block a user