Commit 80b5f382 by John Eskew Committed by Waqas Khalid

Upon import, only raise when none of multiple parents are found for a

block.
parent 78079213
...@@ -2118,16 +2118,21 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase): ...@@ -2118,16 +2118,21 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
if BlockKey.from_usage_key(subtree_root) != source_structure['root']: if BlockKey.from_usage_key(subtree_root) != source_structure['root']:
# find the parents and put root in the right sequence # find the parents and put root in the right sequence
parents = self._get_parents_from_structure(BlockKey.from_usage_key(subtree_root), source_structure) parents = self._get_parents_from_structure(BlockKey.from_usage_key(subtree_root), source_structure)
parent_found = False
for parent in parents: for parent in parents:
if parent not in destination_blocks: # If a parent isn't found in the destination_blocks, it's possible it was renamed
raise ItemNotFoundError(parent) # in the course export. Continue and only throw an exception if *no* parents are found.
orphans.update( if parent in destination_blocks:
self._sync_children( parent_found = True
source_structure['blocks'][parent], orphans.update(
destination_blocks[parent], self._sync_children(
BlockKey.from_usage_key(subtree_root) source_structure['blocks'][parent],
destination_blocks[parent],
BlockKey.from_usage_key(subtree_root)
)
) )
) if len(parents) and not parent_found:
raise ItemNotFoundError(parents)
# update/create the subtree and its children in destination (skipping blacklist) # update/create the subtree and its children in destination (skipping blacklist)
orphans.update( orphans.update(
self._copy_subdag( self._copy_subdag(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment