set PRAGMA=journal_mode=WAL
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,6 +5,7 @@ cmd/server/server
|
||||
cmd/scanner/main
|
||||
cmd/server/main
|
||||
*_bytes.go
|
||||
*_gen.go
|
||||
_test*
|
||||
dist
|
||||
*.sql
|
||||
|
||||
10809
assets/assets_gen.go
10809
assets/assets_gen.go
File diff suppressed because it is too large
Load Diff
2
db/db.go
2
db/db.go
@@ -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",
|
||||
|
||||
BIN
server/ctrlsubsonic/testdata/db
vendored
BIN
server/ctrlsubsonic/testdata/db
vendored
Binary file not shown.
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user