From 951c99338f1d1d8d8d66fa021c06f422877f48d8 Mon Sep 17 00:00:00 2001 From: DYefremov Date: Tue, 5 May 2020 00:02:52 +0300 Subject: [PATCH] added skip upload if file not found --- app/connections.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/connections.py b/app/connections.py index 18a72c0a..eda88ace 100644 --- a/app/connections.py +++ b/app/connections.py @@ -296,7 +296,12 @@ def download_file(ftp, name, save_path, callback): def send_file(file_name, path, ftp, callback): """ Opens the file in binary mode and transfers into receiver """ - with open(path + file_name, "rb") as f: + file_src = path + file_name + if not os.path.isfile(file_src): + log("Uploading file: '{}'. File not found. Skipping.".format(file_src)) + return + + with open(file_src, "rb") as f: callback("Uploading file: {}. Status: {}\n".format(file_name, str(ftp.storbinary("STOR " + file_name, f))))