Detect all file overwrites in autoreload_inotify

mv(1) inside the same filesystem was not detected.

Supporting this case made it necessary to always watch the directory. Turns out
the logic and state keeping between arl_setup() and arl_handle() is easier,
when using different watch descriptors for the file and the directory and not
using a oneshot descriptor for the file.

Requiring an absolute canonical path for arl_setup() simplifies dir and base
name splitting. No need for dirname(3) and basename(3) anymore.
This commit is contained in:
Bert Münnich
2017-05-17 20:16:16 +02:00
parent de3d7827ce
commit a20173a42d
3 changed files with 49 additions and 70 deletions

2
main.c
View File

@ -723,7 +723,7 @@ void run(void)
if (info.fd != -1 && FD_ISSET(info.fd, &fds))
read_info();
if (arl.fd != -1 && FD_ISSET(arl.fd, &fds)) {
if (arl_handle(&arl, files[fileidx].path)) {
if (arl_handle(&arl)) {
/* when too fast, imlib2 can't load the image */
nanosleep(&ten_ms, NULL);
load_image(fileidx);