Handle specially if no time about the last index update found.
The explorer 'currage' now returns -1 if he can not find any value about this. The gencode-remote script handle this value special to not exit if -1 given as value. This fixes the bug ungleich-public/cdist#803
This commit is contained in:
parent
87f30b6053
commit
358e04b2af
2 changed files with 5 additions and 4 deletions
|
@ -24,18 +24,18 @@ case "$type" in
|
||||||
if [ -f "/var/cache/apt/pkgcache.bin" ]; then
|
if [ -f "/var/cache/apt/pkgcache.bin" ]; then
|
||||||
echo $(($(date +"%s")-$(stat --format '%Y' /var/cache/apt/pkgcache.bin)))
|
echo $(($(date +"%s")-$(stat --format '%Y' /var/cache/apt/pkgcache.bin)))
|
||||||
else
|
else
|
||||||
echo 0
|
echo -1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
pacman)
|
pacman)
|
||||||
if [ -d "/var/lib/pacman/sync" ]; then
|
if [ -d "/var/lib/pacman/sync" ]; then
|
||||||
echo $(($(date +"%s")-$(stat --format '%Y' /var/lib/pacman/sync)))
|
echo $(($(date +"%s")-$(stat --format '%Y' /var/lib/pacman/sync)))
|
||||||
else
|
else
|
||||||
echo 0
|
echo -1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
alpine)
|
alpine)
|
||||||
echo 0
|
echo -1
|
||||||
;;
|
;;
|
||||||
*) echo "Your specified type ($type) is currently not supported." >&2
|
*) echo "Your specified type ($type) is currently not supported." >&2
|
||||||
echo "Please contribute an implementation for it if you can." >&2
|
echo "Please contribute an implementation for it if you can." >&2
|
||||||
|
|
|
@ -31,7 +31,8 @@ if [ -n "$maxage" ]; then
|
||||||
if [ "$type" != "apt" ] && [ "$type" != "pacman" ]; then
|
if [ "$type" != "apt" ] && [ "$type" != "pacman" ]; then
|
||||||
echo "ERROR: \"--maxage\" only supported for \"apt\" or \"pacman\" pkg-manager." >&2
|
echo "ERROR: \"--maxage\" only supported for \"apt\" or \"pacman\" pkg-manager." >&2
|
||||||
exit 1
|
exit 1
|
||||||
elif [ "$currage" -lt "$maxage" ]; then
|
# do not exit if no value found (represented as -1)
|
||||||
|
elif [ "$currage" -ne -1 ] && [ "$currage" -lt "$maxage" ]; then
|
||||||
exit 0 # no need to update
|
exit 0 # no need to update
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue