Skip to content

Use --cachedb-dir when SN_CACHEDB_DIR is not set - #144

Closed
Ketan-K17 wants to merge 1 commit into
jonhadfield:mainfrom
Ketan-K17:fix-cachedb-dir-flag
Closed

Ketan-K17 wants to merge 1 commit into
jonhadfield:mainfrom
Ketan-K17:fix-cachedb-dir-flag

Conversation

@Ketan-K17

Copy link
Copy Markdown
Contributor

Fixes #139

Summary

-	out.cacheDBDir = viper.GetString("cachedb_dir")
-	if out.cacheDBDir != "" {
-		out.cacheDBDir = c.String("cachedb-dir")
-	}
+	// the flag defaults to SN_CACHEDB_DIR
+	out.cacheDBDir = c.String("cachedb-dir")

The flag's default is already viper.GetString("cachedb_dir") (main.go:138), so reading the flag covers both the flag and SN_CACHEDB_DIR.

Evidence

New test TestGetOptsCacheDBDirFlag (in cmd/sncli/opts_test.go): with --cachedb-dir /tmp/sn-cache and no env var set, expect /tmp/sn-cache.

  • Before: expected: "/tmp/sn-cache" actual: ""
    After: passes.

Merge Danger

Door: two-way

Blast Radius: cache path

Only runs that pass --cachedb-dir without SN_CACHEDB_DIR change: they now use the directory they asked for.

The flag was read only when SN_CACHEDB_DIR was set, so on its own it
was ignored. The flag already defaults to SN_CACHEDB_DIR, so read it
directly.

Fixes jonhadfield#139
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@jonhadfield

Copy link
Copy Markdown
Owner

Landed on main as e2a8b73.

@jonhadfield jonhadfield closed this Nov 2, 2026
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.

--cachedb-dir is ignored unless SN_CACHEDB_DIR is also set

2 participants