Skip to content

Commit bf97439

Browse files
Fix syncing of the raw files with uppercase extension
1 parent 819259d commit bf97439

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

cloudinary_cli/modules/sync.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ def __init__(self, local_dir, remote_dir, include_hidden, concurrent_workers, fo
8282
To overcome this limitation, cloudinary-cli keeps .cld-sync hidden file in the sync directory that contains a
8383
mapping of the diverse file names. This file keeps tracking on the files and allows syncing in both directions.
8484
"""
85-
self.diverse_file_names = read_json_from_file(self.sync_meta_file, does_not_exist_ok=True)
85+
diverse_file_names = read_json_from_file(self.sync_meta_file, does_not_exist_ok=True)
86+
self.diverse_file_names = dict(
87+
(normalize_file_extension(k), normalize_file_extension(v)) for k, v in diverse_file_names.items())
8688
inverted_diverse_file_names = invert_dict(self.diverse_file_names)
8789

8890
cloudinarized_local_file_names = [self.diverse_file_names.get(f, f) for f in local_file_names]
@@ -109,13 +111,13 @@ def _get_out_of_sync_file_names(self, common_file_names):
109111
local_etag = self.local_files[f]['etag']
110112
remote_etag = self.recovered_remote_files[f]['etag']
111113
if local_etag != remote_etag:
112-
logger.warning(f"{f} is out of sync" +
113-
(f" with '{self.diverse_file_names[f]}" if f in self.diverse_file_names else ""))
114+
logger.warning(f"'{f}' is out of sync" +
115+
(f" with '{self.diverse_file_names[f]}'" if f in self.diverse_file_names else ""))
114116
logger.debug(f"Local etag: {local_etag}. Remote etag: {remote_etag}")
115117
out_of_sync_file_names.add(f)
116118
continue
117119
logger.debug(f"'{f}' is in sync" +
118-
(f" with '{self.diverse_file_names[f]}" if f in self.diverse_file_names else ""))
120+
(f" with '{self.diverse_file_names[f]}'" if f in self.diverse_file_names else ""))
119121

120122
return out_of_sync_file_names
121123

@@ -151,7 +153,7 @@ def save_sync_meta_file(self, upload_results):
151153
diverse_filenames = {}
152154
for local_path, remote_path in upload_results.items():
153155
local = normalize_file_extension(path.relpath(local_path, self.local_dir))
154-
remote = path.relpath(remote_path, self.remote_dir)
156+
remote = normalize_file_extension(path.relpath(remote_path, self.remote_dir))
155157
if local != remote:
156158
diverse_filenames[local] = remote
157159

cloudinary_cli/utils/api_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from cloudinary.utils import cloudinary_url
99

1010
from cloudinary_cli.defaults import logger
11+
from cloudinary_cli.utils.file_utils import normalize_file_extension
1112
from cloudinary_cli.utils.json_utils import print_json, write_json_to_file
1213
from cloudinary_cli.utils.utils import print_help, log_exception, confirm_action, \
1314
get_command_params, merge_responses, normalize_list_params
@@ -31,7 +32,7 @@ def query_cld_folder(folder):
3132

3233
for asset in res['resources']:
3334
rel_path = path.relpath(asset_source(asset), folder)
34-
files[rel_path] = {
35+
files[normalize_file_extension(rel_path)] = {
3536
"type": asset['type'],
3637
"resource_type": asset['resource_type'],
3738
"public_id": asset['public_id'],

0 commit comments

Comments
 (0)