summaryrefslogtreecommitdiffstats
path: root/modules/setting
diff options
context:
space:
mode:
authorNorwin <noerw@users.noreply.github.com>2022-07-30 21:57:41 +0200
committerGitHub <noreply@github.com>2022-07-30 21:57:41 +0200
commit8a330b6b5b7154ce06f5b6695df403e4c8e9f102 (patch)
treead35e26ccd678986b68e4d0bff8b27e9c2b761d6 /modules/setting
parentae3dde1c873320abba49c0cf58c6c87c78cfe334 (diff)
downloadgitea-8a330b6b5b7154ce06f5b6695df403e4c8e9f102.tar.gz
gitea-8a330b6b5b7154ce06f5b6695df403e4c8e9f102.zip
Add setting `SQLITE_JOURNAL_MODE` to enable WAL (#20535)
Co-authored-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/setting')
-rw-r--r--modules/setting/database.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/modules/setting/database.go b/modules/setting/database.go
index 8fdd5f2bcb..af4e780d76 100644
--- a/modules/setting/database.go
+++ b/modules/setting/database.go
@@ -39,6 +39,7 @@ var (
LogSQL bool
Charset string
Timeout int // seconds
+ SQLiteJournalMode string
UseSQLite3 bool
UseMySQL bool
UseMSSQL bool
@@ -91,6 +92,8 @@ func InitDBConfig() {
Database.Path = sec.Key("PATH").MustString(filepath.Join(AppDataPath, "gitea.db"))
Database.Timeout = sec.Key("SQLITE_TIMEOUT").MustInt(500)
+ Database.SQLiteJournalMode = sec.Key("SQLITE_JOURNAL_MODE").MustString("")
+
Database.MaxIdleConns = sec.Key("MAX_IDLE_CONNS").MustInt(2)
if Database.UseMySQL {
Database.ConnMaxLifetime = sec.Key("CONN_MAX_LIFETIME").MustDuration(3 * time.Second)
@@ -136,7 +139,12 @@ func DBConnStr() (string, error) {
if err := os.MkdirAll(path.Dir(Database.Path), os.ModePerm); err != nil {
return "", fmt.Errorf("Failed to create directories: %v", err)
}
- connStr = fmt.Sprintf("file:%s?cache=shared&mode=rwc&_busy_timeout=%d&_txlock=immediate", Database.Path, Database.Timeout)
+ journalMode := ""
+ if Database.SQLiteJournalMode != "" {
+ journalMode = "&_journal_mode=" + Database.SQLiteJournalMode
+ }
+ connStr = fmt.Sprintf("file:%s?cache=shared&mode=rwc&_busy_timeout=%d&_txlock=immediate%s",
+ Database.Path, Database.Timeout, journalMode)
default:
return "", fmt.Errorf("Unknown database type: %s", Database.Type)
}