Skip to content

Commit

Permalink
copy rightItem uuid only if there is some value to add
Browse files Browse the repository at this point in the history
avoids exception in nCopied method
  • Loading branch information
floriangantner committed Nov 14, 2023
1 parent 3bc0f1b commit 58a010b
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public void updateRelationReferences(final Context context, final Relationship r
if (singleDirectionRelationship("right", relationship.getRelationshipType())) {
times = relation.getLeftPlace() - relation.getRightPlace();
}
rightItemsIdsToAdd.addAll(Collections.nCopies(times, relation.getRightItem().getID().toString()));
if (times > 0) {
rightItemsIdsToAdd.addAll(Collections.nCopies(times, relation.getRightItem().getID().toString()));
}
}
if (!rightItemsIdsToAdd.isEmpty()) {

Expand All @@ -79,7 +81,9 @@ public void updateRelationReferences(final Context context, final Relationship r
if (singleDirectionRelationship("left", relationship.getRelationshipType())) {
times = relation.getRightPlace() - relation.getLeftPlace();
}
leftItemsIdsToAdd.addAll(Collections.nCopies(times, relation.getLeftItem().getID().toString()));
if (times > 0) {
leftItemsIdsToAdd.addAll(Collections.nCopies(times, relation.getLeftItem().getID().toString()));
}
}
if (!leftItemsIdsToAdd.isEmpty()) {

Expand All @@ -102,7 +106,9 @@ private void addRightItemsReferences(final Context context, final Relationship r
if (singleDirectionRelationship("right", relationship.getRelationshipType())) {
times = leftItemRelation.getLeftPlace() - leftItemRelation.getRightPlace();
}
rightItemsToAdd.addAll(Collections.nCopies(times, leftItemRelation.getRightItem().getID().toString()));
if (times > 0) {
rightItemsToAdd.addAll(Collections.nCopies(times, leftItemRelation.getRightItem().getID().toString()));
}
}
if (!rightItemsToAdd.isEmpty()) {
indexingService.updateRelationForItem(leftItem.getID().toString(),
Expand All @@ -122,7 +128,9 @@ private void addLeftItemsReferences(final Context context, final Relationship re
if (singleDirectionRelationship("left", relationship.getRelationshipType())) {
times = leftItemRelation.getRightPlace() - leftItemRelation.getLeftPlace();
}
rightItemsToAdd.addAll(Collections.nCopies(times, leftItemRelation.getLeftItem().getID().toString()));
if (times > 0) {
rightItemsToAdd.addAll(Collections.nCopies(times, leftItemRelation.getLeftItem().getID().toString()));
}
}
if (!rightItemsToAdd.isEmpty()) {
indexingService.updateRelationForItem(rightItem.getID().toString(),
Expand Down

0 comments on commit 58a010b

Please sign in to comment.