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)
|
bold=$(tput bold)
|
||||||
dlob=$(tput sgr0)
|
dlob=$(tput sgr0)
|
||||||
|
retries=0
|
||||||
|
|
||||||
# Sync notes via git
|
# Sync notes via git
|
||||||
notesSync() {
|
notesSync() {
|
||||||
# check if online
|
# check if online
|
||||||
test="git.sr.ht"
|
test="git.sr.ht"
|
||||||
time="0.5"
|
time="0.5"
|
||||||
|
max_retries=5
|
||||||
if timeout $time ping -q -c 1 -W 1 $test >/dev/null; then
|
if timeout $time ping -q -c 1 -W 1 $test >/dev/null; then
|
||||||
{
|
{
|
||||||
path="${notes_dir}/"
|
path="${notes_dir}/"
|
||||||
|
|
@ -23,8 +25,14 @@ notesSync() {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
echo ">>> Sync skipped due to timeout ($time)"
|
echo ">>> Sync skipped due to timeout ($time)"
|
||||||
echo "retrying..."
|
retries=$(($retries + 1))
|
||||||
notesSync
|
echo "retrying ($retries/$max_retries)..."
|
||||||
|
if [ $retries -eq $max_retries ]; then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
notesSync
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue