From faf67fcc62307ad8847a78939d5ed222a53e5ea8 Mon Sep 17 00:00:00 2001 From: NRK Date: Sun, 16 Jun 2024 21:07:33 +0000 Subject: fix: autoreload when directory is root (#498) for cases like "/file", `base - filepath` will result in 0 instead of 1. regression introduced in: 94d531fd827457cf71fe7f3808c7a2f531dceba5 Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/498 Reviewed-by: eylles --- autoreload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoreload.c b/autoreload.c index 8b3f6da..8325210 100644 --- a/autoreload.c +++ b/autoreload.c @@ -86,7 +86,7 @@ void arl_add(arl_t *arl, const char *filepath) base = strrchr(filepath, '/'); assert(base != NULL); /* filepath must be result of `realpath(3)` */ - dir = arl_scratch_push(filepath, base - filepath); + dir = arl_scratch_push(filepath, MAX(base - filepath, 1)); add_watch(arl->fd, &arl->wd_dir, dir, IN_CREATE | IN_MOVED_TO); arl->filename = arl_scratch_push(base + 1, strlen(base + 1)); } -- cgit v1.2.3-54-g00ecf