From 80d125ace717a238e193f94778905ca6afdd1a44 Mon Sep 17 00:00:00 2001 From: tech234a <46801700+tech234a@users.noreply.github.com> Date: Sat, 17 Oct 2020 00:29:57 -0400 Subject: [PATCH] Detect failures when transferring to target --- worker.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/worker.py b/worker.py index 4685541..bdf4372 100644 --- a/worker.py +++ b/worker.py @@ -219,10 +219,17 @@ def threadrunner(): print("Waiting 5 minutes...") sleep(300) - if targetloc.startswith("rsync"): - system("rsync -rltv --timeout=300 --contimeout=300 --progress --bwlimit 0 --recursive --partial --partial-dir .rsync-tmp --min-size 1 --no-compress --compress-level 0 directory/"+args.split(":", 1)[1]+"/ "+targetloc) - elif targetloc.startswith("http"): - system("curl -F "+args.split(":", 1)[1]+".zip=@directory/"+args.split(":", 1)[1]+"/"+args.split(":", 1)[1]+".zip "+targetloc) + while True: + if targetloc.startswith("rsync"): + exitinfo = system("rsync -rltv --timeout=300 --contimeout=300 --progress --bwlimit 0 --recursive --partial --partial-dir .rsync-tmp --min-size 1 --no-compress --compress-level 0 directory/"+args.split(":", 1)[1]+"/ "+targetloc) + elif targetloc.startswith("http"): + exitinfo = system("curl -F "+args.split(":", 1)[1]+".zip=@directory/"+args.split(":", 1)[1]+"/"+args.split(":", 1)[1]+".zip "+targetloc) + + if exitinfo == 0: # note that on Unix this isn't necessarily the exit code but it's still 0 upon successful exit + break + else: + print("Error in sending data to target, waiting 30 seconds and trying again.") + sleep(30) size = getsize("directory/"+args.split(":", 1)[1]+"/"+args.split(":", 1)[1]+".zip")