fix(mount): make --cache-dir a session-only override (#85) - #86
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes
Closes #85
Problem
A one-off
mount --cache-dir /tmp/...permanently overwrote the accountconfig: step 5 of
cmd/onecloudriver/mount.goalways wroteacc.Mount.CacheDir = config.CacheDir, even when the value came from theCLI 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,fusermount3failures) until theconfig was manually restored. The flag help read as a session override, but
the value silently became permanent.
Files involved
cmd/onecloudriver/mount.go—--cache-diris now a session-onlyoverride: when the flag is given, the value is used for the mount but
never written back to
acc.Mount.CacheDir. New pure helperbuildPersistedMountConfigcomputes 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 andcommand
Longtext updated accordingly. All other flag overrides(
--cache-ttl,--delta-interval, ...) keep being persisted as before.cmd/onecloudriver/mount_test.go(new) —buildPersistedMountConfigkeeps the previously configured
CacheDirwhen the flag is given (alsowhen 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-configsection and full parameter table document the exception.
docs/ARCHITECTURE.md/docs/ARQUITECTURA.md/docs/ARQUITECTURA.es.md—
--cache-dirrow now notes "session only, never persisted".Test plan
go build ./...go vet ./cmd/onecloudriver/...go test ./cmd/onecloudriver/... -count=1 -short -racegolangci-lint run ./cmd/onecloudriver/...--cache-dir /tmp/x, verify the account JSONcacheDiris unchangedChecklist
Closes #Nissue-N-slugconvention