diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2023-04-10 15:44:49 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2023-04-10 15:44:49 +0300 |
commit | df923aade9354b03fd2dc981fe39bb9a4cbb3fe5 (patch) | |
tree | 3c9954a4186f5fb13e227c62747593efd3457b58 /bin/ak-zblock-cache | |
parent | 025f027d9add0751c9fbaa6ffdc728bba61ca4de (diff) | |
download | arching-kaos-tools-df923aade9354b03fd2dc981fe39bb9a4cbb3fe5.tar.gz arching-kaos-tools-df923aade9354b03fd2dc981fe39bb9a4cbb3fe5.tar.bz2 arching-kaos-tools-df923aade9354b03fd2dc981fe39bb9a4cbb3fe5.zip |
Cache better
Diffstat (limited to 'bin/ak-zblock-cache')
-rwxr-xr-x | bin/ak-zblock-cache | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/bin/ak-zblock-cache b/bin/ak-zblock-cache index 6551796..6d11cde 100755 --- a/bin/ak-zblock-cache +++ b/bin/ak-zblock-cache @@ -1,8 +1,23 @@ #!/bin/bash +PROGRAM="$(basename $0)" +logit(){ + ak-logthis "<$PROGRAM>" "$1" "$2" +} if [ ! -z "$1" ] then - ak-zblock-show "$1" > $AK_ZBLOCKDIR/$1 + if [ -f "$AK_ZBLOCKDIR/$1" ] && [ "$(du -b $AK_ZBLOCKDIR | awk '{ print $1 }')" != "0" ] + then + if [ "$(sha512sum $AK_ZBLOCKDIR/$1 | awk '{ print $1 }')" == "$(ak-zblock-show $1 | sha512sum | awk '{ print $1 }')" ] + then + logit "[INFO]" "Cache already there and updated" + else + logit "[INFO]" "Updating cache" + ak-zblock-show "$1" > $AK_ZBLOCKDIR/$1 + fi + logit "[INFO]" "No cache found. Caching..." + ak-zblock-show "$1" > $AK_ZBLOCKDIR/$1 + fi exit 0 else echo not ok |