feat(notes): retry sync only 5 times
This commit is contained in:
parent
88a154f077
commit
7594336171
1 changed files with 10 additions and 2 deletions
12
functions.sh
12
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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue