Skip to content

Commit

Permalink
Check number of data sources explicitly.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielballan committed May 7, 2024
1 parent 86dd6b1 commit 56338b9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tiled/client/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def _copy_table(source, dest):
def _copy_container(source, dest):
for key, child_node in source.items():
original_data_sources = child_node.include_data_sources().data_sources()
if not original_data_sources:
num_data_sources = len(original_data_sources)
if num_data_sources == 0:
# A container with no data sources is just an organizational
# entity in the database.
if child_node.structure_family == StructureFamily.container:
Expand All @@ -69,7 +70,7 @@ def _copy_container(source, dest):
f"Unable to copy {child_node} which is a "
f"{child_node.structure_family} but has no data sources."
)
else:
elif num_data_sources == 1:
(original_data_source,) = original_data_sources
if original_data_source.management == Management.external:
data_sources = [original_data_source]
Expand All @@ -85,6 +86,12 @@ def _copy_container(source, dest):
structure=original_data_source.structure,
)
]
else:
# As of this writing this is impossible, but we anticipate that
# it may be added someday.
raise NotImplementedError(
"Multiple Data Sources in one Node is not supported."
)
node = dest.new(
key=key,
structure_family=child_node.structure_family,
Expand Down

0 comments on commit 56338b9

Please sign in to comment.