mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-10-26 02:29:08 +01:00
feat: show admin UI warning for SQLite on networked filesystem (#1713)
Co-authored-by: Elias Schneider <login@eliasschneider.com>
This commit is contained in:
co-authored by
Elias Schneider
parent
d258d952b1
commit
29a6fd6c29
@@ -27,6 +27,10 @@ import (
|
||||
sqliteutil "github.com/pocket-id/pocket-id/backend/internal/utils/sqlite"
|
||||
)
|
||||
|
||||
// Records whether the SQLite database was found on a networked filesystem
|
||||
// It's always false when using Postgres
|
||||
var sqliteOnNetworkedFilesystem bool
|
||||
|
||||
func NewDatabase(ctx context.Context) (db *gorm.DB, pg *pgxpool.Pool, err error) {
|
||||
db, pg, err = ConnectDatabase(ctx)
|
||||
if err != nil {
|
||||
@@ -68,6 +72,9 @@ func ConnectDatabase(ctx context.Context) (db *gorm.DB, pg *pgxpool.Pool, err er
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// Detect whether the database lives on a networked filesystem to show a warning in the admin UI
|
||||
sqliteOnNetworkedFilesystem = connector.IsNetworked()
|
||||
|
||||
// We open the connection ourselves, rather than letting Gorm do it, so it goes through the instrumented driver
|
||||
// It also caps in-memory databases to a single connection, which they need to see the whole data
|
||||
sqliteDB, err := sqliteinstrument.Open(connector, sqlInstrumentOptions())
|
||||
|
||||
Reference in New Issue
Block a user