From 1f744f9e0a8efa2209489b5682046d13bd362fb8 Mon Sep 17 00:00:00 2001 From: Norwin Date: Sat, 30 Jul 2022 03:04:02 +0200 Subject: [PATCH] remove the setting, there are enough already --- custom/conf/app.example.ini | 1 - .../doc/advanced/config-cheat-sheet.en-us.md | 1 - modules/setting/database.go | 26 +++++++------------ 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 6dc0e728f4a97..08708948940fa 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -313,7 +313,6 @@ USER = root ;DB_TYPE = sqlite3 ;PATH= ; defaults to data/gitea.db ;SQLITE_TIMEOUT = ; Query timeout defaults to: 500 -;SQLITE_JOURNAL_MODE = ; defaults to DELETE, can be used to enable WAL mode. https://www.sqlite.org/pragma.html#pragma_journal_mode ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index e94c4e6ea461f..31a294e1c9334 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -382,7 +382,6 @@ The following configuration set `Content-Type: application/vnd.android.package-a - `verify-ca`: Enable TLS with verification of the database server certificate against its root certificate. - `verify-full`: Enable TLS and verify the database server name matches the given certificate in either the `Common Name` or `Subject Alternative Name` fields. - `SQLITE_TIMEOUT`: **500**: Query timeout for SQLite3 only. -- `SQLITE_JOURNAL_MODE`: on windows & linux: **WAL**, otherwise **DELETE**: Change journal mode for SQlite3. See [SQlite3 docs](https://www.sqlite.org/pragma.html#pragma_journal_mode) for possible values. - `ITERATE_BUFFER_SIZE`: **50**: Internal buffer size for iterating. - `CHARSET`: **utf8mb4**: For MySQL only, either "utf8" or "utf8mb4". NOTICE: for "utf8mb4" you must use MySQL InnoDB > 5.6. Gitea is unable to check this. - `PATH`: **data/gitea.db**: For SQLite3 only, the database file path. diff --git a/modules/setting/database.go b/modules/setting/database.go index 5b3a52845ed2e..d462ab15328be 100644 --- a/modules/setting/database.go +++ b/modules/setting/database.go @@ -40,7 +40,6 @@ var ( LogSQL bool Charset string Timeout int // seconds - SQliteJournalMode string UseSQLite3 bool UseMySQL bool UseMSSQL bool @@ -90,24 +89,10 @@ func InitDBConfig() { if Database.UseMySQL && defaultCharset != "utf8mb4" { log.Error("Deprecated database mysql charset utf8 support, please use utf8mb4 or convert utf8 to utf8mb4.") } - if Database.UseSQLite3 { Database.Path = sec.Key("PATH").MustString(filepath.Join(AppDataPath, "gitea.db")) Database.Timeout = sec.Key("SQLITE_TIMEOUT").MustInt(500) - - // WAL mode is preferred for better concurent write performance, but needs special VFS driver features, - // which are guaranteed to be available for unix & windows OSes - var defaultJournalMode string - switch runtime.GOOS { - // probably the BSDs are supported too, but i found no information on this - better safe than sorry. - case "windows", "linux": // "darwin", "freebsd", "openbsd", "netbsd": - defaultJournalMode = "WAL" - default: - defaultJournalMode = "DELETE" - } - Database.SQliteJournalMode = sec.Key("SQLITE_JOURNAL_MODE").MustString(defaultJournalMode) } - Database.MaxIdleConns = sec.Key("MAX_IDLE_CONNS").MustInt(2) if Database.UseMySQL { Database.ConnMaxLifetime = sec.Key("CONN_MAX_LIFETIME").MustDuration(3 * time.Second) @@ -153,8 +138,17 @@ 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) } + + // WAL mode is preferred for better concurent write performance, but needs special VFS driver features, + // which are guaranteed to be available for unix & windows OSes: https://www.sqlite.org/wal.html + journalMode := "DELETE" + switch runtime.GOOS { + // probably the BSDs are supported too, but i found no information on this - better safe than sorry. + case "windows", "linux": // "darwin", "freebsd", "openbsd", "netbsd": + journalMode = "WAL" + } connStr = fmt.Sprintf("file:%s?cache=shared&mode=rwc&_busy_timeout=%d&_txlock=immediate&_journal_mode=%s", - Database.Path, Database.Timeout, Database.SQliteJournalMode) + Database.Path, Database.Timeout, journalMode) default: return "", fmt.Errorf("Unknown database type: %s", Database.Type) }