From 23bcb49a5fafb5b44d2ab52c4c2d545eaf2f2ae6 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Sun, 1 Oct 2023 23:49:43 +0200 Subject: [PATCH] FIx force and crash --- commands/tinfoil.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/commands/tinfoil.py b/commands/tinfoil.py index ebd792d..819a9e1 100755 --- a/commands/tinfoil.py +++ b/commands/tinfoil.py @@ -2,6 +2,7 @@ import argparse import os import re +import time import subprocess import sys @@ -25,14 +26,19 @@ def drive_list(path): def download(path, file): - if os.path.isfile(os.path.join(path, file)): + if not force and os.path.isfile(os.path.join(path, file)): return - subprocess.run( - ["rclone", "copy", "-P", "-v", f"{remote}:{path}/{file}", f"{path}/"], - check=True, - stdout=sys.stdout, - ) + try: + subprocess.run( + ["rclone", "copy", "-P", "-v", f"{remote}:{path}/{file}", f"{path}/"], + check=True, + stdout=sys.stdout, + ) + except subprocess.CalledProcessError: + print("Waiting for 10 minutes ...") + time.sleep(10 * 60) + download(path, file) req_titles = requests.get( @@ -62,7 +68,7 @@ for base in bases: id = re_id.group(1) - if not force and id not in titles: + if id not in titles: continue id = id[0:-4]