From 1d886156d55f1c355013f79f21b824a50958b9be Mon Sep 17 00:00:00 2001
From: Deluan <deluan@deluan.com>
Date: Fri, 28 Feb 2020 14:35:32 -0500
Subject: [PATCH] feat: better SQLite3 configuration, to avoid DB contention

---
 conf/configuration.go | 2 +-
 consts/consts.go      | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/conf/configuration.go b/conf/configuration.go
index 876344996..e87a038f3 100644
--- a/conf/configuration.go
+++ b/conf/configuration.go
@@ -83,7 +83,7 @@ func LoadFromFile(confFile string, skipFlags ...bool) {
 		os.Exit(2)
 	}
 	if Server.DbPath == "" {
-		Server.DbPath = filepath.Join(Server.DataFolder, "navidrome.db")
+		Server.DbPath = filepath.Join(Server.DataFolder, consts.DefaultDbPath)
 	}
 	if os.Getenv("PORT") != "" {
 		Server.Port = os.Getenv("PORT")
diff --git a/consts/consts.go b/consts/consts.go
index c9147d59c..5b8481791 100644
--- a/consts/consts.go
+++ b/consts/consts.go
@@ -6,6 +6,7 @@ const (
 	AppName = "navidrome"
 
 	LocalConfigFile     = "./navidrome.toml"
+	DefaultDbPath       = "navidrome.db?cache=shared&_busy_timeout=15000&_journal_mode=WAL"
 	InitialSetupFlagKey = "InitialSetup"
 
 	JWTSecretKey       = "JWTSecret"