Merge branch 'sentriz:master' into ldap_auth
This commit is contained in:
No files matched your search
+12
-17
@@ -10,6 +10,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
@@ -263,7 +264,9 @@ func main() {
|
||||
scrobblers := []scrobble.Scrobbler{lastfmClient, listenbrainzClient}
|
||||
|
||||
resolveProxyPath := func(in string) string {
|
||||
return path.Join(*confProxyPrefix, in)
|
||||
url, _ := url.Parse(in)
|
||||
url.Path = path.Join(*confProxyPrefix, url.Path)
|
||||
return url.String()
|
||||
}
|
||||
|
||||
ctrlAdmin, err := ctrladmin.New(dbc, sessDB, scannr, podcast, lastfmClient, resolveProxyPath, ldapConfig)
|
||||
@@ -317,7 +320,9 @@ func main() {
|
||||
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
||||
}
|
||||
|
||||
errgrp, ctx := errgroup.WithContext(context.Background())
|
||||
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||
defer cancel()
|
||||
errgrp, ctx := errgroup.WithContext(ctx)
|
||||
|
||||
errgrp.Go(func() error {
|
||||
defer logJob("http")()
|
||||
@@ -334,7 +339,10 @@ func main() {
|
||||
if *confTLSCert != "" && *confTLSKey != "" {
|
||||
return server.ListenAndServeTLS(*confTLSCert, *confTLSKey)
|
||||
}
|
||||
return server.ListenAndServe()
|
||||
if err := server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
errgrp.Go(func() error {
|
||||
@@ -458,20 +466,7 @@ func main() {
|
||||
return nil
|
||||
})
|
||||
|
||||
errShutdown := errors.New("shutdown")
|
||||
|
||||
errgrp.Go(func() error {
|
||||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
case <-sigChan:
|
||||
return errShutdown
|
||||
}
|
||||
})
|
||||
|
||||
if err := errgrp.Wait(); err != nil && !errors.Is(err, errShutdown) {
|
||||
if err := errgrp.Wait(); err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -291,7 +291,11 @@ func (c *Client) GetCurrentUser(user *db.User) (User, error) {
|
||||
}
|
||||
|
||||
func (c *Client) makeRequest(method string, params url.Values) (LastFM, error) {
|
||||
req, _ := http.NewRequest(method, BaseURL, nil)
|
||||
req, err := http.NewRequest(method, BaseURL, nil)
|
||||
if err != nil {
|
||||
return LastFM{}, fmt.Errorf("create request: %w", err)
|
||||
}
|
||||
|
||||
req.URL.RawQuery = params.Encode()
|
||||
|
||||
resp, err := c.httpClient.Do(req)
|
||||
|
||||
@@ -75,7 +75,11 @@ func (c *Client) Scrobble(user db.User, track scrobble.Track, stamp time.Time, s
|
||||
submitURL := fmt.Sprintf("%s%s", user.ListenBrainzURL, submitPath)
|
||||
authHeader := fmt.Sprintf("Token %s", user.ListenBrainzToken)
|
||||
|
||||
req, _ := http.NewRequest(http.MethodPost, submitURL, &payloadBuf)
|
||||
req, err := http.NewRequest(http.MethodPost, submitURL, &payloadBuf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create submit request: %w", err)
|
||||
}
|
||||
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
req.Header.Add("Authorization", authHeader)
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
type TagLib struct{}
|
||||
|
||||
func (TagLib) CanRead(absPath string) bool {
|
||||
switch ext := filepath.Ext(absPath); ext {
|
||||
switch ext := strings.ToLower(filepath.Ext(absPath)); ext {
|
||||
case ".mp3", ".flac", ".aac", ".m4a", ".m4b", ".ogg", ".opus", ".wma", ".wav", ".wv":
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user