shiori/internal/database/sqlite_openbsd.go
Paco Esteban 02247b215b
refactor: allow specific sqlite engine for OpenBSD (#780)
* remove dependencies that use syscall.Syscall*

OpenBSD will be removing direct access to `syscall(2)` soon.
Shiori will stop working because of this, as some of its dependencies
rely heavily on the use of `syscall.Syscall*`, which ends up using
`syscall(2)`.  This commit removes those dependencies by reverting back
to use github.com/mattn/go-sqlite3 instead of modernc.org/sqlite to deal
with the sqlite database backend.

* add ~emersion/go-sqlite3-fts5

* enable cgo to check ci

* fts5 build flag

* split sqlite logic using build flags

* disable cgo again

* added ci test for bsd systems

* remove openbsd ci

* Revert "remove openbsd ci"

This reverts commit f394148385.

* fix makefile go_test_flags

---------

Co-authored-by: Felipe M <me@fmartingr.com>
Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
2024-05-02 16:38:16 +02:00

26 lines
598 B
Go

//go:build openbsd
// +build openbsd
package database
import (
"context"
"github.com/jmoiron/sqlx"
"github.com/pkg/errors"
_ "git.sr.ht/~emersion/go-sqlite3-fts5"
_ "github.com/mattn/go-sqlite3"
)
// OpenSQLiteDatabase creates and open connection to new SQLite3 database.
func OpenSQLiteDatabase(ctx context.Context, databasePath string) (sqliteDB *SQLiteDatabase, err error) {
// Open database
db, err := sqlx.ConnectContext(ctx, "sqlite3", databasePath)
if err != nil {
return nil, errors.WithStack(err)
}
sqliteDB = &SQLiteDatabase{dbbase: dbbase{*db}}
return sqliteDB, nil
}