mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 14:20:55 +03:00
sqlite: execute PRAGMA optimize on startup
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -215,7 +215,7 @@ func initializeSQLiteProvider(basePath string) error {
|
||||
providerLog(logger.LevelDebug, "sqlite database handle created, connection string: %q", connectionString)
|
||||
dbHandle.SetMaxOpenConns(1)
|
||||
provider = &SQLiteProvider{dbHandle: dbHandle}
|
||||
return nil
|
||||
return executePragmaOptimize(dbHandle)
|
||||
}
|
||||
|
||||
func (p *SQLiteProvider) checkAvailability() error {
|
||||
@@ -773,6 +773,14 @@ func (p *SQLiteProvider) normalizeError(err error, fieldType int) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func executePragmaOptimize(dbHandle *sql.DB) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), defaultSQLQueryTimeout)
|
||||
defer cancel()
|
||||
|
||||
_, err := dbHandle.ExecContext(ctx, "PRAGMA optimize;")
|
||||
return err
|
||||
}
|
||||
|
||||
/*func setPragmaFK(dbHandle *sql.DB, value string) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), longSQLQueryTimeout)
|
||||
defer cancel()
|
||||
|
||||
Reference in New Issue
Block a user