pwreset: Stop daemon on restart, dont fail if json is malformed
daemon now stops on the RESTART signal, and when it fails to read JSON, it no longer stops the whole daemon.
This commit is contained in:
+3
-3
@@ -40,13 +40,13 @@ func (app *appContext) StartPWR() {
|
||||
}
|
||||
defer watcher.Close()
|
||||
|
||||
done := make(chan bool)
|
||||
go pwrMonitor(app, watcher)
|
||||
err = watcher.Add(path)
|
||||
if err != nil {
|
||||
app.err.Printf("Failed to start password reset daemon: %s", err)
|
||||
}
|
||||
<-done
|
||||
|
||||
<-RESTART
|
||||
}
|
||||
|
||||
// PasswordReset represents a passwordreset-xyz.json file generated by Jellyfin.
|
||||
@@ -77,7 +77,7 @@ func pwrMonitor(app *appContext, watcher *fsnotify.Watcher) {
|
||||
err = json.Unmarshal(data, &pwr)
|
||||
if len(pwr.Pin) == 0 || err != nil {
|
||||
app.debug.Printf("PWR: Failed to read PIN: %v", err)
|
||||
return
|
||||
continue
|
||||
}
|
||||
app.info.Printf("New password reset for user \"%s\"", pwr.Username)
|
||||
if currentTime := time.Now(); pwr.Expiry.After(currentTime) {
|
||||
|
||||
Reference in New Issue
Block a user