diff options
Diffstat (limited to 'worker')
-rw-r--r-- | worker/handlers/register.go | 12 | ||||
-rw-r--r-- | worker/lib/watchers/fsevents.go (renamed from worker/lib/watchers/darwin/darwin.go) | 4 | ||||
-rw-r--r-- | worker/lib/watchers/inotify.go (renamed from worker/lib/watchers/linux/linux.go) | 7 | ||||
-rw-r--r-- | worker/watcher_darwin.go | 6 | ||||
-rw-r--r-- | worker/watcher_enabled.go | 3 | ||||
-rw-r--r-- | worker/worker_enabled.go | 2 |
6 files changed, 14 insertions, 20 deletions
diff --git a/worker/handlers/register.go b/worker/handlers/register.go index c94a256e..4123665f 100644 --- a/worker/handlers/register.go +++ b/worker/handlers/register.go @@ -29,15 +29,15 @@ func GetHandlerForScheme(scheme string, worker *types.Worker) (types.Backend, er type WatcherFactoryFunc func() (types.FSWatcher, error) -var watcherFactories map[string]WatcherFactoryFunc = make(map[string]WatcherFactoryFunc) +var watcherFactory WatcherFactoryFunc -func RegisterWatcherFactory(os string, fn WatcherFactoryFunc) { - watcherFactories[os] = fn +func RegisterWatcherFactory(fn WatcherFactoryFunc) { + watcherFactory = fn } func NewWatcher() (types.FSWatcher, error) { - if fn, ok := watcherFactories[runtime.GOOS]; ok { - return fn() + if watcherFactory == nil { + return nil, fmt.Errorf("Unsupported OS: %s", runtime.GOOS) } - return nil, fmt.Errorf("Unsupported OS: %s", runtime.GOOS) + return watcherFactory() } diff --git a/worker/lib/watchers/darwin/darwin.go b/worker/lib/watchers/fsevents.go index e20761f3..7b657999 100644 --- a/worker/lib/watchers/darwin/darwin.go +++ b/worker/lib/watchers/fsevents.go @@ -1,7 +1,7 @@ //go:build darwin // +build darwin -package darwin +package watchers import ( "time" @@ -13,7 +13,7 @@ import ( ) func init() { - handlers.RegisterWatcherFactory("darwin", newDarwinWatcher) + handlers.RegisterWatcherFactory(newDarwinWatcher) } type darwinWatcher struct { diff --git a/worker/lib/watchers/linux/linux.go b/worker/lib/watchers/inotify.go index 473bb05e..027ef4f2 100644 --- a/worker/lib/watchers/linux/linux.go +++ b/worker/lib/watchers/inotify.go @@ -1,4 +1,7 @@ -package linux +//go:build !darwin +// +build !darwin + +package watchers import ( "git.sr.ht/~rjarry/aerc/log" @@ -8,7 +11,7 @@ import ( ) func init() { - handlers.RegisterWatcherFactory("linux", newInotifyWatcher) + handlers.RegisterWatcherFactory(newInotifyWatcher) } type inotifyWatcher struct { diff --git a/worker/watcher_darwin.go b/worker/watcher_darwin.go deleted file mode 100644 index fa1af712..00000000 --- a/worker/watcher_darwin.go +++ /dev/null @@ -1,6 +0,0 @@ -//go:build darwin -// +build darwin - -package worker - -import _ "git.sr.ht/~rjarry/aerc/worker/lib/watchers/darwin" diff --git a/worker/watcher_enabled.go b/worker/watcher_enabled.go deleted file mode 100644 index 16333f43..00000000 --- a/worker/watcher_enabled.go +++ /dev/null @@ -1,3 +0,0 @@ -package worker - -import _ "git.sr.ht/~rjarry/aerc/worker/lib/watchers/linux" diff --git a/worker/worker_enabled.go b/worker/worker_enabled.go index a644525f..697ca402 100644 --- a/worker/worker_enabled.go +++ b/worker/worker_enabled.go @@ -3,7 +3,7 @@ package worker // the following workers are always enabled import ( _ "git.sr.ht/~rjarry/aerc/worker/imap" + _ "git.sr.ht/~rjarry/aerc/worker/lib/watchers" _ "git.sr.ht/~rjarry/aerc/worker/maildir" - _ "git.sr.ht/~rjarry/aerc/worker/mbox" ) |