Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions dependencies/server_alive_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function online_test {
# Before download
if [[ $confirm_online == "true" ]]; then
# Continue trying according to settings
quittime=$(( $scriptstart + $retry_download_max*60*60 )) # Hours
quittime=$(( ScriptStartTime + retry_download_max*60 )) # Minutes
echo "INFO: Keep trying until $(date --date=@$quittime)"
if [[ $(date +%s) -lt $quittime ]]; then
echo -e "INFO: Stopping session and trying again $retry_download"mins" later\n"
Expand Down Expand Up @@ -71,8 +71,9 @@ function online {
# Function to check if the server is writable
function writeable {
writeable_test
local writeable_status=$?
if [[ -f "$server_check_file" ]]; then rm "$server_check_file"; fi;
if [[ $? -eq 0 ]]; then
if [[ $writeable_status -eq 0 ]]; then
echo -e "\e[00;32m [OK]\e[00m"
is_online="0"
else
Expand All @@ -81,7 +82,7 @@ function writeable {
# Before download
if [[ $confirm_online == "true" ]]; then
# Continue trying according to settings
quittime=$(( $scriptstart + $retry_download_max*60*60 )) # Hours
quittime=$(( ScriptStartTime + retry_download_max*60 )) # Minutes
echo "INFO: Keep trying until $(date --date=@$quittime)"
if [[ $(date +%s) -lt $quittime ]]; then
echo -e "INFO: Stopping session and trying again $retry_download"mins" later\n"
Expand All @@ -93,14 +94,23 @@ function writeable {
queue run # Running new session
fi
fi
is_online="1"
# Online test
while [[ $retry_count -lt $retries ]]; do
echo -e "\e[00;31m [RETRYING]\e[00m"
let retry_count++
writeable_test
writeable_status=$?
if [[ -f "$server_check_file" ]]; then rm "$server_check_file"; fi;
if [[ $writeable_status -eq 0 ]]; then
is_online="0"
break
fi
done
# If still offline
sed "3s#.*#*************************** SERVER INFO: SERVER NOT WRITEABLE#" -i $logfile
is_online="1"
# If still not writeable
if [[ $is_online -ne 0 ]]; then
sed "3s#.*#*************************** SERVER INFO: SERVER NOT WRITEABLE#" -i $logfile
is_online="1"
fi
fi
}
2 changes: 1 addition & 1 deletion dependencies/server_size_management.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function server_sizemanagement {
fi
done
elif [[ $mode == "check" ]]; then
quittime=$(( $scriptstart + $retry_download_max*60*60 )) #hours
quittime=$(( ScriptStartTime + retry_download_max*60 )) # Minutes
echo "INFO: Keep trying until $(date --date=@$quittime)"
while [[ $(date +%s) -lt $quittime ]]; do
echo -e "\e[00;31mERROR: Looking up free space failed for some reason!\e[00m"
Expand Down
13 changes: 11 additions & 2 deletions dependencies/transfer_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ function transfer_already_moved {
}

function transfer {
local lftp_exclude quittime waittime complete_preexisting=false
local lftp_exclude quittime waittime complete_preexisting=false transfer_attempt=1

# Prepare new transfer
{
Expand Down Expand Up @@ -353,6 +353,15 @@ function transfer {
break
fi

# Give up when all allowed attempts are used
if [[ $transfer_attempt -ge ${retries:-3} ]]; then
echo -e "\e[00;31mERROR: Transfer failed after $transfer_attempt attempt(s)!\e[00m"
transfer_process "stop-process-bar"
queue fail
break
fi
transfer_attempt=$(( transfer_attempt + 1 ))

quittime=$(( ScriptStartTime + retry_download_max*60 ))

# Check if it's time to quit
Expand All @@ -365,7 +374,7 @@ function transfer {
break
else
echo -e "\e[00;31mERROR: Transfer failed for some reason!\e[00m"
echo "INFO: Retrying until $(date --date=@$quittime '+%d/%m/%y-%a-%H:%M:%S')"
echo "INFO: Retrying until $(date --date=@$quittime '+%d/%m/%y-%a-%H:%M:%S') (attempt $transfer_attempt of ${retries:-3})"

# Stop the transfer process, pause session, and retry after a delay
transfer_process "stop-process-bar"
Expand Down