Skip to content

Commit

Permalink
Fixed that meta-file load order was ignored for subdirs when no data …
Browse files Browse the repository at this point in the history
…files to upload
  • Loading branch information
raulikak committed May 2, 2024
1 parent 02f7fc3 commit 60927d8
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tcsfw/client_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,24 @@ def upload_file(self, url: str, file_data: BinaryIO, meta_json: Dict):
def upload_directory(self, url: str, path: pathlib.Path):
"""Upload directory"""
files = sorted(path.iterdir())

meta_file = path / "00meta.json"
if meta_file.exists():
with meta_file.open() as f:
meta_json = json.load(f)
file_load_order = meta_json.get("file_order", [])
if file_load_order:
# sort files by file_load_order
files = FileMetaInfo.sort_load_order(files, file_load_order)
else:
meta_json = None # not {}

# files to upload
to_upload = self.filter_data_files(files)

if meta_file.exists() and to_upload:
if meta_json is not None and to_upload:
to_upload.insert(0, meta_file) # upload also meta file, make it first
self.logger.info("%s", meta_file.as_posix())
with meta_file.open() as f:
meta_json = json.load(f)
file_load_order = meta_json.get("file_order", [])
if file_load_order:
# sort subdirectories based on file_load_order
files = FileMetaInfo.sort_load_order(files, file_load_order)

# meta file exists -> upload files from here
self.logger.info("%s/", path.as_posix())
Expand Down

0 comments on commit 60927d8

Please sign in to comment.