Ignore changes to $WATCHED_DIR itself.
This fixes the dreaded "sometimes sends empty reports" bug metche has had
since forever.
Implementation-wise, this requires making $FIND_OPTS initialized in
context_config, as $WATCHED_DIR changes depending on the context (host or
VServer).
Closes: https://labs.riseup.net/code/issues/3933
intrigeri
11 years ago
255 | 255 | done |
256 | 256 | set +o noglob |
257 | 257 | |
258 | # How to use $FIND_OPTS: | |
259 | # - $FIND_OPTS should appear unquoted between: | |
260 | # . the (optional) target files and directories | |
261 | # . the (compulsory) action, such as -print or -exec | |
262 | # - 'set -o noglob' has to be run before any $FIND_OPTS use | |
263 | # - 'set +o noglob' has to be run after any $FIND_OPTS use | |
264 | FIND_OPTS="" | |
258 | # How to use $_FIND_OPTS: | |
259 | # - 'set -o noglob' has to be run before any $_FIND_OPTS use | |
260 | # - 'set +o noglob' has to be run after any $_FIND_OPTS use | |
261 | _FIND_OPTS="" | |
265 | 262 | set -o noglob |
266 | # DO NOT fix me: the final -or at the end of $FIND_OPTS is really needed | |
263 | # DO NOT fix me: the final -or at the end of $_FIND_OPTS is really needed | |
267 | 264 | for pattern in $EXCLUDES; do |
268 | FIND_OPTS="$FIND_OPTS -path */$pattern -prune -or" | |
265 | _FIND_OPTS="$_FIND_OPTS -path */$pattern -prune -or" | |
269 | 266 | done |
270 | 267 | set +o noglob |
271 | 268 | |
347 | 344 | # Check the existence of WATCHED_DIR |
348 | 345 | test -d "$WATCHED_DIR" || \ |
349 | 346 | fatal "$WATCHED_DIR directory (built from WATCHED_DIR) does not exist." |
347 | ||
348 | # Initialize $FIND_OPTS -- how to use it: | |
349 | # - 'set -o noglob' has to be run before any $FIND_OPTS use | |
350 | # - 'set +o noglob' has to be run after any $FIND_OPTS use | |
351 | # - $FIND_OPTS should appear unquoted between: | |
352 | # . the (optional) target files and directories | |
353 | # . the (compulsory) action, such as -print or -exec | |
354 | set -o noglob | |
355 | FIND_OPTS="-path $WATCHED_DIR -or $_FIND_OPTS" | |
356 | set +o noglob | |
350 | 357 | |
351 | 358 | # Initialize WATCHED_PARENT |
352 | 359 | WATCHED_PARENT=`dirname $WATCHED_DIR` |