Fix SIGUSR1 work when ScanInterval=0

This commit is contained in:
Deluan
2021-04-29 13:10:10 -04:00
parent a35de2bfd1
commit 8a07bac2a2
3 changed files with 45 additions and 19 deletions
+1 -8
View File
@@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"os"
"strconv"
"sync"
"time"
@@ -40,10 +39,7 @@ type FolderScanner interface {
Scan(ctx context.Context, lastModifiedSince time.Time, progress chan uint32) error
}
var (
isScanning utils.AtomicBool
sigChan = make(chan os.Signal, 1)
)
var isScanning utils.AtomicBool
type scanner struct {
folders map[string]FolderScanner
@@ -87,9 +83,6 @@ func (s *scanner) Run(ctx context.Context, interval time.Duration) {
select {
case <-ticker.C:
continue
case sig := <-sigChan:
log.Info(ctx, "Received signal, triggering a new scan", "signal", sig)
continue
case <-ctx.Done():
return
}
-17
View File
@@ -1,17 +0,0 @@
// +build !windows
// +build !plan9
package scanner
import (
"os"
"os/signal"
"syscall"
)
func init() {
signals := []os.Signal{
syscall.SIGUSR1,
}
signal.Notify(sigChan, signals...)
}