aboutsummaryrefslogtreecommitdiff
path: root/worker/handlers/register.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-09 22:29:48 +0100
commit5a6a11ddad23e24ffaf2eabaef60f07c20138992 (patch)
tree2724d705377aeb645b525f548ad6c4306b603640 /worker/handlers/register.go
parent96d85a905f33c5b85b558c1059284db719292096 (diff)
downloadaerc-fs.tar.gz
aerc-fs.zip
fswatcher: fix bsd supportfs
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>
Diffstat (limited to 'worker/handlers/register.go')
-rw-r--r--worker/handlers/register.go12
1 files changed, 6 insertions, 6 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()
}