Skip to content

Commit 8b6dbb6

Browse files
committed
Handle ZFS event watcher errors gracefully and provide user guidance for permissions
1 parent de4665d commit 8b6dbb6

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

internal/zfs/zfs_evemt_watcher.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ func WatchZpoolEvents(ctx context.Context) error {
5656
parseZpoolEvents(stdout, startTime, debouncedUpdate)
5757

5858
if err := cmd.Wait(); err != nil {
59-
logging.Error("zpool events listener exited: %s", err.Error())
6059
return err
6160
}
6261

@@ -132,7 +131,20 @@ func parseZpoolEvents(reader io.Reader, startTime time.Time, onUpdate func()) {
132131
func AddZpoolEventWatcherActor(g *run.Group, ctx context.Context) {
133132
g.Add(func() error {
134133
logging.Info("Starting ZFS event watcher...")
135-
return WatchZpoolEvents(ctx)
134+
135+
err := WatchZpoolEvents(ctx)
136+
137+
// If it crashed but the application ISN'T shutting down (ctx is not canceled)
138+
if err != nil && ctx.Err() == nil {
139+
logging.Warning("⚠️ Real-time updates disabled. Missing permissions to watch ZFS events.")
140+
logging.Warning("Run 'sudo zfs-file-history setup' to enable real-time UI refreshes.")
141+
}
142+
143+
// CRITICAL: Block until the application shuts down!
144+
// If we return here, oklog/run will forcefully kill the UI and exit the app.
145+
<-ctx.Done()
146+
147+
return nil
136148
}, func(err error) {
137149
logging.Debug("Stopping ZFS event watcher...")
138150
})

0 commit comments

Comments
 (0)