Keep the empty host for a state_dir starting with //

With OmitHost set, a state_dir starting with // gave a db_url starting
file://, and SQLite read the first directory name as a host, so pixa
failed to start. OmitHost is now left off for such a directory: the URL
starts file://// and SQLite reads an empty host followed by the path.
Every other state_dir gives the same URL as before.

Model: opus-5-5
This commit is contained in:
2026-10-16 01:42:43 +00:00
parent 1911489815
commit 51528c92b4
3 changed files with 14 additions and 9 deletions
+4 -2
View File
@@ -359,11 +359,13 @@ func newFromSmartConfig(sc *smartconfig.Config) (*Config, error) {
// the directory name, which SQLite decodes back, so the URL names exactly
// this file. OmitHost writes file:/var/lib/pixa/... instead of
// file:///var/lib/pixa/..., and keeps a relative stateDir from being read
// as a host name.
// as a host name. A stateDir starting with // keeps the empty host, so the
// URL starts file://// and SQLite does not read the first directory name
// as a host.
func defaultDBURL(stateDir string) string {
dbURL := url.URL{
Scheme: "file",
OmitHost: true,
OmitHost: !strings.HasPrefix(stateDir, "//"),
Path: stateDir + "/state.sqlite3",
RawQuery: "_pragma=journal_mode(WAL)",
}