aboutsummaryrefslogtreecommitdiffstats
path: root/worker/lib/watchers/linux/linux.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-03-09 22:26:03 +0100
committerRobin Jarry <robin@jarry.cc>2023-03-10 09:19:09 +0100
commit60078b8452867c9ab40c9623ef63169bdb090c83 (patch)
treef4ea0a0b0cbeac06a3262d042826b2a8484bc1fc /worker/lib/watchers/linux/linux.go
parent5ae7a23e1ec99f1e552967ed9d058133b6c860c6 (diff)
downloadaerc-60078b8452867c9ab40c9623ef63169bdb090c83.tar.gz
fswatcher: fix bsd support
Fix the following error when running maildir on freebsd: could not create file system watcher: Unsupported OS: freebsd Do not register based on os type. Register based on supported API. Rename linux -> inotify and darwin -> fsevents. Only build fsevents on darwin, and inotify on all other platforms. Fixes: a0935a3de0ce ("worker/lib: implement an fswatcher interface") Reported-by: Jens Grassel <jens@wegtam.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Jens Grassel <jens@wegtam.com>
Diffstat (limited to 'worker/lib/watchers/linux/linux.go')
-rw-r--r--worker/lib/watchers/linux/linux.go73
1 files changed, 0 insertions, 73 deletions
diff --git a/worker/lib/watchers/linux/linux.go b/worker/lib/watchers/linux/linux.go
deleted file mode 100644
index 473bb05e..00000000
--- a/worker/lib/watchers/linux/linux.go
+++ /dev/null
@@ -1,73 +0,0 @@
-package linux
-
-import (
- "git.sr.ht/~rjarry/aerc/log"
- "git.sr.ht/~rjarry/aerc/worker/handlers"
- "git.sr.ht/~rjarry/aerc/worker/types"
- "github.com/fsnotify/fsnotify"
-)
-
-func init() {
- handlers.RegisterWatcherFactory("linux", newInotifyWatcher)
-}
-
-type inotifyWatcher struct {
- w *fsnotify.Watcher
- ch chan *types.FSEvent
-}
-
-func newInotifyWatcher() (types.FSWatcher, error) {
- watcher := &inotifyWatcher{
- ch: make(chan *types.FSEvent),
- }
- w, err := fsnotify.NewWatcher()
- if err != nil {
- return nil, err
- }
- watcher.w = w
-
- go watcher.watch()
- return watcher, nil
-}
-
-func (w *inotifyWatcher) watch() {
- defer log.PanicHandler()
- for ev := range w.w.Events {
- // we only care about files being created, removed or renamed
- switch ev.Op {
- case fsnotify.Create:
- w.ch <- &types.FSEvent{
- Operation: types.FSCreate,
- Path: ev.Name,
- }
- case fsnotify.Remove:
- w.ch <- &types.FSEvent{
- Operation: types.FSRemove,
- Path: ev.Name,
- }
- case fsnotify.Rename:
- w.ch <- &types.FSEvent{
- Operation: types.FSRename,
- Path: ev.Name,
- }
- default:
- continue
- }
- }
-}
-
-func (w *inotifyWatcher) Configure(root string) error {
- return w.w.Add(root)
-}
-
-func (w *inotifyWatcher) Events() chan *types.FSEvent {
- return w.ch
-}
-
-func (w *inotifyWatcher) Add(p string) error {
- return w.w.Add(p)
-}
-
-func (w *inotifyWatcher) Remove(p string) error {
- return w.w.Remove(p)
-}