mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Disable noti subscription for the same dir
This commit is contained in:
parent
79cbc40a7f
commit
c66c941a97
29
nnn.c
29
nnn.c
|
@ -2083,6 +2083,7 @@ browse(char *ipath, char *ifilter)
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
int r, fd, presel;
|
int r, fd, presel;
|
||||||
enum action sel = SEL_RUNARG + 1;
|
enum action sel = SEL_RUNARG + 1;
|
||||||
|
bool dir_changed = FALSE;
|
||||||
|
|
||||||
xstrlcpy(path, ipath, PATH_MAX);
|
xstrlcpy(path, ipath, PATH_MAX);
|
||||||
xstrlcpy(fltr, ifilter, LINE_MAX);
|
xstrlcpy(fltr, ifilter, LINE_MAX);
|
||||||
|
@ -2095,11 +2096,17 @@ browse(char *ipath, char *ifilter)
|
||||||
|
|
||||||
begin:
|
begin:
|
||||||
#ifdef LINUX_INOTIFY
|
#ifdef LINUX_INOTIFY
|
||||||
if (inotify_wd >= 0)
|
if (dir_changed && inotify_wd >= 0) {
|
||||||
inotify_rm_watch(inotify_fd, inotify_wd);
|
inotify_rm_watch(inotify_fd, inotify_wd);
|
||||||
|
inotify_wd = -1;
|
||||||
|
dir_changed = FALSE;
|
||||||
|
}
|
||||||
#elif defined(BSD_KQUEUE)
|
#elif defined(BSD_KQUEUE)
|
||||||
if (event_fd >= 0)
|
if (dir_changed && event_fd >= 0) {
|
||||||
close(event_fd);
|
close(event_fd);
|
||||||
|
event_fd = -1;
|
||||||
|
dir_changed = FALSE;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (populate(path, oldpath, fltr) == -1) {
|
if (populate(path, oldpath, fltr) == -1) {
|
||||||
|
@ -2108,11 +2115,14 @@ begin:
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LINUX_INOTIFY
|
#ifdef LINUX_INOTIFY
|
||||||
inotify_wd = inotify_add_watch(inotify_fd, path, INOTIFY_MASK);
|
if (inotify_wd == -1)
|
||||||
|
inotify_wd = inotify_add_watch(inotify_fd, path, INOTIFY_MASK);
|
||||||
#elif defined(BSD_KQUEUE)
|
#elif defined(BSD_KQUEUE)
|
||||||
event_fd = open(path, O_EVTONLY);
|
if (event_fd == -1) {
|
||||||
if (event_fd >= 0)
|
event_fd = open(path, O_EVTONLY);
|
||||||
EV_SET(&events_to_monitor[0], event_fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, KQUEUE_FFLAGS, 0, path);
|
if (event_fd >= 0)
|
||||||
|
EV_SET(&events_to_monitor[0], event_fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, KQUEUE_FFLAGS, 0, path);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -2163,6 +2173,8 @@ nochange:
|
||||||
|
|
||||||
/* Save last working directory */
|
/* Save last working directory */
|
||||||
xstrlcpy(lastdir, path, PATH_MAX);
|
xstrlcpy(lastdir, path, PATH_MAX);
|
||||||
|
dir_changed = TRUE;
|
||||||
|
|
||||||
xstrlcpy(path, dir, PATH_MAX);
|
xstrlcpy(path, dir, PATH_MAX);
|
||||||
/* Reset filter */
|
/* Reset filter */
|
||||||
xstrlcpy(fltr, ifilter, LINE_MAX);
|
xstrlcpy(fltr, ifilter, LINE_MAX);
|
||||||
|
@ -2201,6 +2213,7 @@ nochange:
|
||||||
|
|
||||||
/* Save last working directory */
|
/* Save last working directory */
|
||||||
xstrlcpy(lastdir, path, PATH_MAX);
|
xstrlcpy(lastdir, path, PATH_MAX);
|
||||||
|
dir_changed = TRUE;
|
||||||
|
|
||||||
xstrlcpy(path, newpath, PATH_MAX);
|
xstrlcpy(path, newpath, PATH_MAX);
|
||||||
oldpath[0] = '\0';
|
oldpath[0] = '\0';
|
||||||
|
@ -2412,6 +2425,7 @@ nochange:
|
||||||
|
|
||||||
/* Save last working directory */
|
/* Save last working directory */
|
||||||
xstrlcpy(lastdir, path, PATH_MAX);
|
xstrlcpy(lastdir, path, PATH_MAX);
|
||||||
|
dir_changed = TRUE;
|
||||||
|
|
||||||
/* Save the newly opted dir in path */
|
/* Save the newly opted dir in path */
|
||||||
xstrlcpy(path, newpath, PATH_MAX);
|
xstrlcpy(path, newpath, PATH_MAX);
|
||||||
|
@ -2445,6 +2459,7 @@ nochange:
|
||||||
|
|
||||||
/* Save last working directory */
|
/* Save last working directory */
|
||||||
xstrlcpy(lastdir, path, PATH_MAX);
|
xstrlcpy(lastdir, path, PATH_MAX);
|
||||||
|
dir_changed = TRUE;
|
||||||
|
|
||||||
xstrlcpy(path, dstdir, PATH_MAX);
|
xstrlcpy(path, dstdir, PATH_MAX);
|
||||||
oldpath[0] = '\0';
|
oldpath[0] = '\0';
|
||||||
|
@ -2475,6 +2490,7 @@ nochange:
|
||||||
|
|
||||||
xstrlcpy(newpath, tmp, PATH_MAX);
|
xstrlcpy(newpath, tmp, PATH_MAX);
|
||||||
xstrlcpy(lastdir, path, PATH_MAX);
|
xstrlcpy(lastdir, path, PATH_MAX);
|
||||||
|
dir_changed = TRUE;
|
||||||
xstrlcpy(path, newpath, PATH_MAX);
|
xstrlcpy(path, newpath, PATH_MAX);
|
||||||
oldpath[0] = '\0';
|
oldpath[0] = '\0';
|
||||||
/* Reset filter */
|
/* Reset filter */
|
||||||
|
@ -2525,6 +2541,7 @@ nochange:
|
||||||
|
|
||||||
/* Save last working directory */
|
/* Save last working directory */
|
||||||
xstrlcpy(lastdir, path, PATH_MAX);
|
xstrlcpy(lastdir, path, PATH_MAX);
|
||||||
|
dir_changed = TRUE;
|
||||||
|
|
||||||
/* Save the newly opted dir in path */
|
/* Save the newly opted dir in path */
|
||||||
xstrlcpy(path, newpath, PATH_MAX);
|
xstrlcpy(path, newpath, PATH_MAX);
|
||||||
|
|
Loading…
Reference in a new issue