protect from empty ~/.zen/bunkerbox/history_qo-op.json

This commit is contained in:
fred 2022-04-08 20:16:39 +02:00
parent 010d6c7892
commit b21288f13f
1 changed files with 1 additions and 0 deletions

View File

@ -128,6 +128,7 @@ echo "##########################################################################
if [[ "$(cat ~/.zen/bunkerbox/choice 2>/dev/null)" == "qo-op" ]]; then
IPNSL="/ipns/$(ipfs key list -l | grep 'qo-op' | cut -f 1 -d ' ')"
ipfs get -o ~/.zen/bunkerbox/history_qo-op.json $IPNSL/history.json # Get actual IPNS qo-op history.json
[[ ! -f ~/.zen/bunkerbox/history_qo-op.json || $(cat ~/.zen/bunkerbox/history_qo-op.json 2>/dev/null) == "" ]] && cp ${MY_PATH}/templates/data/history.json ~/.zen/bunkerbox/history_qo-op.json
[[ $(cat ~/.zen/bunkerbox/history_qo-op.json | jq .Videos[].link | grep $VUID) ]] && echo "VIDEO DEJA DANS IPFS... CONTINUE" && echo && cp ~/.zen/bunkerbox/history_qo-op.json ~/.zen/bunkerbox/history.json && continue
# JSON FUSION
jq -s '.[0] * .[1]' ~/.zen/bunkerbox/history_qo-op.json ~/.zen/bunkerbox/history.json | jq -M '.Videos |= unique_by(.link)' > ~/.zen/bunkerbox/history.fusion.json