Escape state_dir in the db_url derived from it (closes #290)
check / check (push) Canceled after 0s

The derived db_url put state_dir into a file: URL as it was, so SQLite
decoded a %HH in the name and ended the path at a ? or #, and the
journal mode parameter was lost. It is now built with net/url, which
percent-encodes the directory name; SQLite decodes it back and opens
state.sqlite3 in that directory. OmitHost keeps the usual form
file:/var/lib/pixa/state.sqlite3 and a relative state_dir a path.

Model: opus-5-5
This commit is contained in:
2026-10-16 00:45:38 +00:00
parent 2ef9e57840
commit bfd486cd95
3 changed files with 26 additions and 7 deletions
+13 -2
View File
@@ -338,8 +338,19 @@ func newFromSmartConfig(sc *smartconfig.Config) (*Config, error) {
settingName(keyDBURL), errValueEmpty)
}
// The driver sets the journal mode only through a _pragma parameter.
c.DBURL = fmt.Sprintf("file:%s/state.sqlite3?_pragma=journal_mode(WAL)", c.StateDir)
// The driver sets the journal mode only through a _pragma
// parameter. String() percent-encodes any %, ? or # in 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
// state_dir from being read as a host name.
dbURL := url.URL{
Scheme: "file",
OmitHost: true,
Path: c.StateDir + "/state.sqlite3",
RawQuery: "_pragma=journal_mode(WAL)",
}
c.DBURL = dbURL.String()
}
if loader.err != nil {