]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: combine inotifywait and timeout to detect delete event
authorAlain Spineux <alain@baculasystems.com>
Mon, 17 Jan 2022 17:30:57 +0000 (18:30 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:57 +0000 (13:56 +0200)
- it looks like inotify could miss some event

regress/scripts/blab.py

index cca5e300dea40e13ea673564e9a7977c4291f9db..a7426b470c29259bd302c3291a4f2f60646bc7bd 100755 (executable)
@@ -661,7 +661,11 @@ class Lab:
         f.write("""\
 # The plugin unlink the file just after open()
 # echo "$$ `date` $@" >> /tmp/log
-while [ -f {tmp}/dedupstreams.conf ] ; do sleep 1; done
+
+# if inotifywait is installed then use it to "instantly" detect that the file
+# as been deleted from the direcory (aka "consumed") else wait 1s
+wait_cmd="`which inotifywait` -t 5 -e delete {tmp}" || wait_cmd="sleep 1"
+while [ -f {tmp}/dedupstreams.conf ] ; do $wait_cmd; done
 for var in "$@" ; do
    if [ "${{var}}" = "next" ] ; then
       var=0