From 8f456ac19e5e80eaa911645f882d184a534f87a4 Mon Sep 17 00:00:00 2001 From: Albert Cervin Date: Wed, 14 Aug 2024 21:34:38 +0200 Subject: Do not reload buffer if it could not be watched Previously it tried to reload the buffer even though it could not be watched. --- src/dged/reactor-epoll.c | 8 +------- src/main/main.c | 5 ++++- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/dged/reactor-epoll.c b/src/dged/reactor-epoll.c index ead0296..4c83b49 100644 --- a/src/dged/reactor-epoll.c +++ b/src/dged/reactor-epoll.c @@ -84,13 +84,7 @@ uint32_t reactor_watch_file(struct reactor *reactor, const char *path, // TODO: change if we get more event types mask = IN_CLOSE_WRITE; - int fd = inotify_add_watch(reactor->inotify_fd, path, mask); - if (fd == -1) { - minibuffer_echo_timeout(4, "failed to watch %s: %s", path, strerror(errno)); - return 0; - } - - return (uint32_t)fd; + return (uint32_t)inotify_add_watch(reactor->inotify_fd, path, mask); } void reactor_unwatch_file(struct reactor *reactor, uint32_t id) { diff --git a/src/main/main.c b/src/main/main.c index ee954f9..8e3e862 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -125,7 +125,10 @@ void update_file_watches(struct reactor *reactor) { message("re-watching: %s", w->buffer->filename); w->watch_id = reactor_watch_file(reactor, w->buffer->filename, FileWritten); - reload_buffer(w->buffer); + + if (w->watch_id != INVALID_WATCH) { + reload_buffer(w->buffer); + } } } } -- cgit v1.2.3