22from functools import reduce
33from itertools import product
44from os import remove
5- from os .path import split , join as path_join , abspath
5+ from os .path import join as path_join , abspath
66
77from click import command , argument , option , style
88from cloudinary import api
99
1010from cloudinary_cli .utils .api_utils import query_cld_folder , upload_file , download_file
1111from cloudinary_cli .utils .file_utils import walk_dir , delete_empty_dirs , get_destination_folder
1212from cloudinary_cli .utils .json_utils import print_json
13- from cloudinary_cli .utils .utils import logger , run_tasks_concurrently , confirm_action , get_user_action
13+ from cloudinary_cli .utils .utils import logger , run_tasks_concurrently , get_user_action
1414
1515DELETE_ASSETS_BATCH_SIZE = 100
1616
@@ -88,8 +88,10 @@ def push(self):
8888 return False
8989
9090 files_to_push = self .unique_local_file_names | self .out_of_sync_file_names
91- to_upload = list (filter (lambda x : split (x )[1 ][0 ] != "." , files_to_push ))
92- logger .info (f"Uploading { len (to_upload )} items to Cloudinary folder '{ self .remote_dir } '" )
91+ if not files_to_push :
92+ return True
93+
94+ logger .info (f"Uploading { len (files_to_push )} items to Cloudinary folder '{ self .remote_dir } '" )
9395
9496 options = {
9597 'use_filename' : True ,
@@ -98,7 +100,7 @@ def push(self):
98100 'resource_type' : 'auto'
99101 }
100102 uploads = []
101- for file in to_upload :
103+ for file in files_to_push :
102104 folder = get_destination_folder (self .remote_dir , file )
103105
104106 uploads .append ((self .local_files [file ]['path' ], {** options , 'folder' : folder }))
@@ -145,12 +147,14 @@ def pull(self):
145147
146148 files_to_pull = self .unique_remote_file_names | self .out_of_sync_file_names
147149
150+ if not files_to_pull :
151+ return True
152+
148153 logger .info (f"Downloading { len (files_to_pull )} files from Cloudinary" )
149154 downloads = []
150155 for file in files_to_pull :
151156 remote_file = self .remote_files [file ]
152- file_name = file + "." + remote_file ['format' ] if remote_file ['resource_type' ] != 'raw' else file
153- local_path = abspath (path_join (self .local_dir , file_name ))
157+ local_path = abspath (path_join (self .local_dir , file ))
154158
155159 downloads .append ((remote_file , local_path ))
156160
0 commit comments