aboutsummaryrefslogtreecommitdiffstats
path: root/watcher.go
diff options
context:
space:
mode:
Diffstat (limited to 'watcher.go')
-rw-r--r--watcher.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/watcher.go b/watcher.go
index 7b823da..2b56bb4 100644
--- a/watcher.go
+++ b/watcher.go
@@ -1,6 +1,7 @@
package main
import (
+ "context"
"log"
"os"
"path/filepath"
@@ -12,7 +13,7 @@ import (
ignore "github.com/sabhiram/go-gitignore"
)
-func watch(hostDir, dataDir string, manifest *Manifest, rules *ignore.GitIgnore, dryRun, verbose bool) error {
+func watch(ctx context.Context, hostDir, dataDir string, manifest *Manifest, rules *ignore.GitIgnore, dryRun, verbose bool) error {
watcher, err := fsnotify.NewWatcher()
if err != nil {
return err
@@ -28,6 +29,9 @@ func watch(hostDir, dataDir string, manifest *Manifest, rules *ignore.GitIgnore,
for {
select {
+ case <-ctx.Done():
+ return nil
+
case event, ok := <-watcher.Events:
if !ok {
return nil