From 50d2518afeeed879077b7440b8fe18bbdde4476d Mon Sep 17 00:00:00 2001
From: Lubomir Bucek <lubomir.bucek@eox.at>
Date: Thu, 24 Sep 2020 14:36:43 +0200
Subject: [PATCH] check for empty upload earlier

---
 preprocessor/preprocessor/preprocess.py     | 4 ++++
 preprocessor/preprocessor/transfer/swift.py | 2 --
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/preprocessor/preprocessor/preprocess.py b/preprocessor/preprocessor/preprocess.py
index 17a04908..93f8b7b5 100644
--- a/preprocessor/preprocessor/preprocess.py
+++ b/preprocessor/preprocessor/preprocess.py
@@ -223,6 +223,10 @@ def preprocess_file(config: dict, file_path: os.PathLike, use_dir: os.PathLike=N
         uploader = get_uploader(
             target_config['type'], target_config.get('args'), target_config.get('kwargs')
         )
+        if len(os.listdir('upload')) == 0:
+            # end here, so not only metadata file is uploaded
+            raise Exception('No data files to upload, aborting.')
+        
         paths_for_upload = ['upload', 'extra']
         upload_filenames = []
         for path_to_upload in paths_for_upload:
diff --git a/preprocessor/preprocessor/transfer/swift.py b/preprocessor/preprocessor/transfer/swift.py
index 333c9f03..b5178397 100644
--- a/preprocessor/preprocessor/transfer/swift.py
+++ b/preprocessor/preprocessor/transfer/swift.py
@@ -65,8 +65,6 @@ class Uploader(Base):
     """
     def upload(self, local_path: Union[os.PathLike, List[os.PathLike]], remote_dir: os.PathLike) -> List[os.PathLike]:
         paths = local_path if isinstance(local_path, List) else [local_path]
-        if len(paths) == 0:
-            raise Exception('No files are were found to be uploaded.')
         remote_paths = [
             os.path.join(
                 remote_dir,
-- 
GitLab