set PRAGMA=journal_mode=WAL

This commit is contained in:
sentriz
2019-07-24 12:22:25 +01:00
parent 03af38be37
commit 310e752015
5 changed files with 13 additions and 10815 deletions

1
.gitignore vendored
View File

@@ -5,6 +5,7 @@ cmd/server/server
cmd/scanner/main
cmd/server/main
*_bytes.go
*_gen.go
_test*
dist
*.sql

File diff suppressed because it is too large Load Diff

View File

@@ -36,6 +36,7 @@ func New(path string) (*DB, error) {
}
db.SetLogger(log.New(os.Stdout, "gorm ", 0))
db.DB().SetMaxOpenConns(dbMaxOpenConns)
db.Exec("PRAGMA journal_mode=WAL;")
db.AutoMigrate(
model.Artist{},
model.Track{},
@@ -44,6 +45,7 @@ func New(path string) (*DB, error) {
model.Play{},
model.Album{},
)
// TODO: don't log if user already exists
db.FirstOrCreate(&model.User{}, model.User{
Name: "admin",
Password: "admin",

Binary file not shown.

View File

@@ -2,6 +2,7 @@ package server
import (
"bytes"
"fmt"
"net/http"
"path/filepath"
"time"
@@ -27,13 +28,16 @@ func New(db *db.DB, musicPath string, listenAddr string) *Server {
MusicPath: musicPath,
}
router := mux.NewRouter()
// jamstash seems to call "musicFolderSettings.view" to start a scan. notice
// that there is no "/rest/" prefix, so i doesn't fit in with the nice router,
// custom handler, middleware. etc setup that we've got in `SetupSubsonic()`.
// instead lets redirect to down there and use the scan endpoint
router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// make the admin page the default
http.Redirect(w, r, "/admin/home", http.StatusMovedPermanently)
})
router.HandleFunc("/musicFolderSettings.view", func(w http.ResponseWriter, r *http.Request) {
oldParams := r.URL.Query().Encode()
redirectTo := "/rest/startScan.view?" + oldParams
// jamstash seems to call "musicFolderSettings.view" to start a scan. notice
// that there is no "/rest/" prefix, so i doesn't fit in with the nice router,
// instead lets redirect to down there and use the scan endpoint
// custom handler, middleware. etc setup that we've got in `SetupSubsonic()`.
redirectTo := fmt.Sprintf("/rest/startScan.view?%s", r.URL.Query().Encode())
http.Redirect(w, r, redirectTo, http.StatusMovedPermanently)
})
router.Use(ctrlBase.WithLogging)