Skip to content

fix(mount): make --cache-dir a session-only override (#85) - #86

Merged
FROSADO merged 1 commit into
mainfrom
issue-85-session-only-cache-dir
Aug 16, 2026
Merged

fix(mount): make --cache-dir a session-only override (#85)#86
FROSADO merged 1 commit into
mainfrom
issue-85-session-only-cache-dir

Conversation

@FROSADO

@FROSADO FROSADO commented Aug 16, 2026

Copy link
Copy Markdown
Owner

Closes

Closes #85

Problem

A one-off mount --cache-dir /tmp/... permanently overwrote the account
config: step 5 of cmd/onecloudriver/mount.go always wrote
acc.Mount.CacheDir = config.CacheDir, even when the value came from the
CLI flag. Future mounts (e.g. systemd service restarts) then pointed at the
temporary path — and once that path was deleted, both user services
crash-looped (activating auto-restart, fusermount3 failures) until the
config was manually restored. The flag help read as a session override, but
the value silently became permanent.

Files involved

  • cmd/onecloudriver/mount.go--cache-dir is now a session-only
    override
    : when the flag is given, the value is used for the mount but
    never written back to acc.Mount.CacheDir. New pure helper
    buildPersistedMountConfig computes the config to save (unit-testable).
    When the flag is used, the startup line prints
    Cache: <dir> (session only, not saved to account config). Flag help and
    command Long text updated accordingly. All other flag overrides
    (--cache-ttl, --delta-interval, ...) keep being persisted as before.
  • cmd/onecloudriver/mount_test.go (new) — buildPersistedMountConfig
    keeps the previously configured CacheDir when the flag is given (also
    when the persisted value is empty), persists it when no flag is given, and
    always persists the remaining scalar fields.
  • docs/MANUAL.md / docs/MANUAL.es.md — cache flag table, persisted-config
    section and full parameter table document the exception.
  • docs/ARCHITECTURE.md / docs/ARQUITECTURA.md / docs/ARQUITECTURA.es.md
    --cache-dir row now notes "session only, never persisted".

Test plan

  • go build ./...
  • go vet ./cmd/onecloudriver/...
  • go test ./cmd/onecloudriver/... -count=1 -short -race
  • golangci-lint run ./cmd/onecloudriver/...
  • Manual: mount with --cache-dir /tmp/x, verify the account JSON
    cacheDir is unchanged

Checklist

  • Issue linked with Closes #N
  • Branch follows the issue-N-slug convention
  • Commit messages follow Conventional Commits
  • Tests added/updated for the change
  • CI checks pass (Build, Tests (unit + race), Tests (integration FUSE), Lint, Security Audit)

A one-off `mount --cache-dir /tmp/...` permanently overwrote the
account JSON (`acc.Mount.CacheDir`), so future mounts (e.g. systemd
service restarts) pointed at a temporary path — which, once deleted,
crash-looped the services until the config was manually restored.

- mount.go: track whether --cache-dir came from the flag and exclude
  it from the persisted config (new buildPersistedMountConfig helper);
  print "(session only, not saved to account config)" when used.
- All other flag overrides (cache-ttl, delta-interval, ...) are safe
  scalars and keep being persisted as before.
- Tests: buildPersistedMountConfig keeps the previous CacheDir when
  the flag is given (also when the persisted value is empty) and
  persists all other fields; persists CacheDir when no flag is set.
- Docs: flag help, command Long text, MANUAL.md/.es, ARCHITECTURE*
  now document the session-only semantics.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 77.331% (+0.06%) from 77.276% — issue-85-session-only-cache-dir into main

@FROSADO
FROSADO merged commit 297b857 into main Aug 16, 2026
9 checks passed
@FROSADO
FROSADO deleted the issue-85-session-only-cache-dir branch August 16, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(mount): do not persist one-off --cache-dir into account config (or warn for temporary paths)

2 participants