]> git.eshelyaron.com Git - emacs.git/commitdiff
Make file-notify--call-handler more robust
authorMichael Albinus <michael.albinus@gmx.de>
Wed, 11 Jun 2025 17:20:43 +0000 (19:20 +0200)
committerEshel Yaron <me@eshelyaron.com>
Wed, 18 Jun 2025 08:11:04 +0000 (10:11 +0200)
* lisp/filenotify.el (file-notify--call-handler): Make it more
robust.  (Bug#78712)

(cherry picked from commit 81a3e4e51167be51c63eae682331210bc62f7280)

lisp/filenotify.el

index 61a517200cec6c8601b33aef2ff3a514f271b08e..f31a4353513b1b059990b5f6bbadf623623b1e90 100644 (file)
@@ -233,16 +233,18 @@ It is nil or a `file-notify--rename' defstruct where the cookie can be nil.")
          (and (stringp file1)
               (string-equal (file-notify--watch-filename watch)
                             (file-name-nondirectory file1))))
-    (when file-notify-debug
-      (message
-       "file-notify-callback %S %S %S %S %S %S %S"
-       desc action file file1 watch
-       (file-notify--watch-absolute-filename watch)
-       (file-notify--watch-directory watch)))
-    (funcall (file-notify--watch-callback watch)
-             (if file1
-                 (list desc action file file1)
-               (list desc action file)))))
+    ;; The callback could have removed in `file-notify--rm-descriptor'.
+    (when (file-notify--watch-callback watch)
+      (when file-notify-debug
+        (message
+         "file-notify-callback %S %S %S %S %S %S %S"
+         desc action file file1 watch
+         (file-notify--watch-absolute-filename watch)
+         (file-notify--watch-directory watch)))
+      (funcall (file-notify--watch-callback watch)
+               (if file1
+                   (list desc action file file1)
+                 (list desc action file))))))
 
 (defun file-notify--handle-event (desc actions file file1-or-cookie)
   "Handle an event returned from file notification.