Subject: Re: bug#21435: 25.0.50; file-notify has problems after renames

From: Michael Albinus <[email-masked]>
Date: Thu, 10 Sep 2015 13:09:36 +0200

Eli Zaretskii <[email-masked]> writes:

>> # mv /tmp/xxx ~/tmp/
>
> This doesn't work at all on w32 (I used d:/usr/eli/data instead of
> ~/tmp), it reports removal and addition (and also a bogus 2nd
> removal):
>
> ======================================================================
> 1 -> (file-notify-handle-event (file-notify (100286608 removed "xxx")
> file-notify-callback))
> | 2 -> (myhandler2 (100286608 deleted "d:/usr/eli/data/xxx"))
> | 2 <- myhandler2: nil
> 1 <- file-notify-handle-event: nil
> ======================================================================
> 1 -> (file-notify-handle-event (file-notify (100286608 added "xxx")
> file-notify-callback))
> | 2 -> (myhandler2 (100286608 created "d:/usr/eli/data/xxx"))
> | 2 <- myhandler2: nil
> 1 <- file-notify-handle-event: nil
> ======================================================================
> 1 -> (file-notify-handle-event (file-notify (100286560 removed "xxx")
> file-notify-callback))
> | 2 -> (myhandler1 (100286560 deleted "d:/tmp/xxx"))
> | 2 <- myhandler1: nil
> 1 <- file-notify-handle-event: nil
>
> Let me know what I should look into or which additional information I
> can give you about this.

`file-notify-handle-event' is called directly by the low-level library,
w32notify here. It sends the events

(file-notify (100286608 removed "xxx"))
(file-notify (100286608 added "xxx"))
(file-notify (100286560 removed "xxx"))

The first two events are raised by the file name handler for d:/usr/eli/data.
Maybe "xxx" did exist already in that directory? In this case, it would be
OK to remove it first.

The last event comes from from file name handler for d:/tmp - this looks
OK. Well, the order of the events is not as expected (the third event
shall be the first one), but we never gave a promise for a canonical order.

I would say, that w32notify does not send the renamed-from and
renamed-to events, as expected. Maybe they are sent only in case of
renaming a file in the same directory? Say

# mv /tmp/xxx /tmp/yyy

Best regards, Michael.