Extract Grammaratur, Dregarnuhr, Geduldh, Mestionora, Ordoschnellic, Schutzaria, Kunstzeal and Seheweit behind compatible application contracts. Include accumulated editor resilience, navigation and theme UX, remote CLI, storage/schema and DR groundwork, tests and design/operations documentation. Verified: uncached full Go suite; go vet ./...; race tests for all eight components; 11 targeted Chromium tests; Node suites; 19 Python CLI tests; reproducible editor build. No push, release tag or deployment in this checkpoint.
26 lines
609 B
Go
26 lines
609 B
Go
package db
|
|
|
|
import (
|
|
"database/sql"
|
|
"net/url"
|
|
"path/filepath"
|
|
)
|
|
|
|
// OpenReadOnly deliberately does not migrate, set journal_mode, or create a DB.
|
|
func OpenReadOnly(path string) (*sql.DB, error) {
|
|
path, err := filepath.Abs(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
dsn := (&url.URL{Scheme: "file", Path: path, RawQuery: url.Values{"mode": {"ro"}, "_pragma": {"query_only(1)", "busy_timeout(5000)"}}.Encode()}).String()
|
|
database, err := sql.Open("sqlite", dsn)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if err = database.Ping(); err != nil {
|
|
database.Close()
|
|
return nil, err
|
|
}
|
|
return database, nil
|
|
}
|