diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-14 10:40:44 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-14 10:40:44 +0300 |
| commit | d49376f71dd8defebf80f901ecb60ab99f0f4906 (patch) | |
| tree | 749322d2bf5c33d28ff95b77ebc674d69435c31c /internal/authkeys/store.go | |
| parent | ff749457e392288e29dbf553bf8e0e64cc8b6401 (diff) | |
n3: validate SQLite with PingContext after Open
Call db.PingContext in storage.Open and authkeys.OpenStore; close DB and
return wrapped errors on failure. Add tests for canceled context and
invalid directory path.
Made-with: Cursor
Diffstat (limited to 'internal/authkeys/store.go')
| -rw-r--r-- | internal/authkeys/store.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/internal/authkeys/store.go b/internal/authkeys/store.go index 9f0a8b2..7848ef8 100644 --- a/internal/authkeys/store.go +++ b/internal/authkeys/store.go @@ -38,6 +38,10 @@ func OpenStore(ctx context.Context, path string) (*Store, error) { if err != nil { return nil, fmt.Errorf("open auth db: %w", err) } + if err := db.PingContext(ctx); err != nil { + db.Close() + return nil, fmt.Errorf("ping auth db: %w", err) + } if _, err := db.ExecContext(ctx, "PRAGMA foreign_keys = OFF"); err != nil { db.Close() return nil, fmt.Errorf("pragma: %w", err) |
