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/scanner/main
|
||||||
cmd/server/main
|
cmd/server/main
|
||||||
*_bytes.go
|
*_bytes.go
|
||||||
|
*_gen.go
|
||||||
_test*
|
_test*
|
||||||
dist
|
dist
|
||||||
*.sql
|
*.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.SetLogger(log.New(os.Stdout, "gorm ", 0))
|
||||||
db.DB().SetMaxOpenConns(dbMaxOpenConns)
|
db.DB().SetMaxOpenConns(dbMaxOpenConns)
|
||||||
|
db.Exec("PRAGMA journal_mode=WAL;")
|
||||||
db.AutoMigrate(
|
db.AutoMigrate(
|
||||||
model.Artist{},
|
model.Artist{},
|
||||||
model.Track{},
|
model.Track{},
|
||||||
@@ -44,6 +45,7 @@ func New(path string) (*DB, error) {
|
|||||||
model.Play{},
|
model.Play{},
|
||||||
model.Album{},
|
model.Album{},
|
||||||
)
|
)
|
||||||
|
// TODO: don't log if user already exists
|
||||||
db.FirstOrCreate(&model.User{}, model.User{
|
db.FirstOrCreate(&model.User{}, model.User{
|
||||||
Name: "admin",
|
Name: "admin",
|
||||||
Password: "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 (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
@@ -27,13 +28,16 @@ func New(db *db.DB, musicPath string, listenAddr string) *Server {
|
|||||||
MusicPath: musicPath,
|
MusicPath: musicPath,
|
||||||
}
|
}
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
// jamstash seems to call "musicFolderSettings.view" to start a scan. notice
|
router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
// that there is no "/rest/" prefix, so i doesn't fit in with the nice router,
|
// make the admin page the default
|
||||||
// custom handler, middleware. etc setup that we've got in `SetupSubsonic()`.
|
http.Redirect(w, r, "/admin/home", http.StatusMovedPermanently)
|
||||||
// instead lets redirect to down there and use the scan endpoint
|
})
|
||||||
router.HandleFunc("/musicFolderSettings.view", func(w http.ResponseWriter, r *http.Request) {
|
router.HandleFunc("/musicFolderSettings.view", func(w http.ResponseWriter, r *http.Request) {
|
||||||
oldParams := r.URL.Query().Encode()
|
// jamstash seems to call "musicFolderSettings.view" to start a scan. notice
|
||||||
redirectTo := "/rest/startScan.view?" + oldParams
|
// 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)
|
http.Redirect(w, r, redirectTo, http.StatusMovedPermanently)
|
||||||
})
|
})
|
||||||
router.Use(ctrlBase.WithLogging)
|
router.Use(ctrlBase.WithLogging)
|
||||||
|
|||||||
Reference in New Issue
Block a user