mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-10-21 00:59:04 +02: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())
|
||||
|
||||
@@ -176,7 +176,7 @@ func registerRoutes(r *gin.Engine, db *gorm.DB, svc *services, rateLimitServices
|
||||
controller.NewUserGroupController(apiGroup, authMiddleware, svc.appConfigService, svc.userGroupService)
|
||||
svc.apiModule.RegisterRoutes(apiGroup, authMiddleware.Add())
|
||||
controller.NewCustomClaimController(apiGroup, authMiddleware, svc.customClaimService)
|
||||
controller.NewVersionController(apiGroup, authMiddleware, svc.versionService)
|
||||
svc.environmentModule.RegisterRoutes(apiGroup, authMiddleware.WithAdminNotRequired().Add())
|
||||
svc.scimSyncModule.RegisterRoutes(apiGroup, authMiddleware.Add())
|
||||
svc.userSignUpModule.RegisterRoutes(apiGroup,
|
||||
authMiddleware.Add(),
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/pocket-id/pocket-id/backend/internal/devicelogin"
|
||||
"github.com/pocket-id/pocket-id/backend/internal/email"
|
||||
"github.com/pocket-id/pocket-id/backend/internal/emailverification"
|
||||
"github.com/pocket-id/pocket-id/backend/internal/environment"
|
||||
"github.com/pocket-id/pocket-id/backend/internal/geolite"
|
||||
"github.com/pocket-id/pocket-id/backend/internal/ldapsync"
|
||||
"github.com/pocket-id/pocket-id/backend/internal/oidc"
|
||||
@@ -37,7 +38,6 @@ type services struct {
|
||||
customClaimService *service.CustomClaimService
|
||||
oidcService *service.OidcService
|
||||
userGroupService *service.UserGroupService
|
||||
versionService *service.VersionService
|
||||
fileStorage storage.FileStorage
|
||||
|
||||
apiKeyModule *apikey.Module
|
||||
@@ -51,6 +51,7 @@ type services struct {
|
||||
oneTimeAccessModule *onetimeaccess.Module
|
||||
emailVerificationModule *emailverification.Module
|
||||
apiModule *api.Module
|
||||
environmentModule *environment.Module
|
||||
actors *local.Host
|
||||
}
|
||||
|
||||
@@ -247,7 +248,10 @@ func initServices(
|
||||
return nil, fmt.Errorf("failed to create email verification module: %w", err)
|
||||
}
|
||||
|
||||
svc.versionService = service.NewVersionService(httpClient)
|
||||
svc.environmentModule = environment.New(environment.Dependencies{
|
||||
HTTPClient: httpClient,
|
||||
SQLiteOnNetworkedFilesystem: sqliteOnNetworkedFilesystem,
|
||||
})
|
||||
|
||||
return svc, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user