diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-09-24 15:46:24 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-09-24 15:48:43 +0200 |
| commit | 4fa1b3e89e1fc3902217c701711acd4d4c9ab01c (patch) | |
| tree | de0d34060fd2795746a90aa3f4d781da6d9af0bb | |
| parent | 173528aef50a4b452acdd8ec9aff13f25c3e092c (diff) | |
thumbnail/main.c: Use new cftw interface
This was a leftover from the following commit:
commit 173528aef50a4b452acdd8ec9aff13f25c3e092c
Author: Xavier Del Campo Romero
Date: Wed Sep 24 11:01:31 2025 +0200
Make search non-blocking
Thanks to a new feature in libweb, it is now possible to generate HTTP
responses asynchronously i.e., without blocking other clients if the
response takes a long time to generate.
This now allow users to search for files or directories without blocking
other users, regardless how much time the search operation takes.
This required cftw to deviate from the POSIX-like, blocking interface it
had so far, and has been replaced now with a non-blocking interface, so
that directories are inspected one entry at a time.
| -rw-r--r-- | thumbnail/main.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/thumbnail/main.c b/thumbnail/main.c index bbdc7f0..4629ff8 100644 --- a/thumbnail/main.c +++ b/thumbnail/main.c @@ -567,16 +567,33 @@ static int generate_existing(const char *const user, .force = force }; - printf("Scanning existing files...\n"); + int ret = -1; + enum cftw_state state; + struct cftw *const c = cftw(user, do_generate, &a); - if (cftw(user, do_generate, &a)) + if (!c) { fprintf(stderr, "%s: cftw failed\n", __func__); - return -1; + goto end; + } + + printf("Scanning existing files...\n"); + + while ((state = cftw_step(c)) == CFTW_AGAIN) + ; + + if (state) + { + fprintf(stderr, "%s: cftw_step failed\n", __func__); + goto end; } printf("Finished scanning\n"); - return 0; + cftw_free(c); + ret = 0; + +end: + return ret; } static void handle_signal(const int signum) |
