fix: return a empty json if there are no repo to stat

This commit is contained in:
Ravinou 2023-10-08 16:57:13 +02:00
parent 3e63f187e8
commit ea68dea83f
No known key found for this signature in database
GPG key ID: EEEE670C40F6A4D7

View file

@ -26,6 +26,10 @@ fi
# Default value if .env not exists
: "${home:=/home/borgwarehouse}"
stat --format='{"repositoryName":"%n","lastSave":%Y}' \
if [ -n "$(find ${home}/repos -mindepth 1 -maxdepth 1 -type d)" ]; then
stat --format='{"repositoryName":"%n","lastSave":%Y}' \
${home}/repos/*/integrity* |
jq --slurp '[.[] | .repositoryName = (.repositoryName | split("/")[-2])]'
jq --slurp '[.[] | .repositoryName = (.repositoryName | split("/")[-2])]'
else
echo "[]"
fi