diff --git a/functions.sh b/functions.sh index a219a1f..77bfeaf 100644 --- a/functions.sh +++ b/functions.sh @@ -2,12 +2,14 @@ bold=$(tput bold) dlob=$(tput sgr0) +retries=0 # Sync notes via git notesSync() { # check if online test="git.sr.ht" time="0.5" + max_retries=5 if timeout $time ping -q -c 1 -W 1 $test >/dev/null; then { path="${notes_dir}/" @@ -23,8 +25,14 @@ notesSync() { } else echo ">>> Sync skipped due to timeout ($time)" - echo "retrying..." - notesSync + retries=$(($retries + 1)) + echo "retrying ($retries/$max_retries)..." + if [ $retries -eq $max_retries ]; then + return + else + notesSync + fi + fi }