Skip to content

Commit

Permalink
Make sure a folder is not inserted twice in tree
Browse files Browse the repository at this point in the history
  • Loading branch information
barijaona committed Aug 7, 2024
1 parent 0fbc341 commit a4c8c8f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Vienna/Sources/Main window/FoldersTree.m
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ -(BOOL)loadTree:(NSArray *)listOfFolders rootNode:(TreeNode *)node
NSInteger nextChildId = (node == self.rootNode) ? [Database sharedManager].firstFolderId : node.folder.firstChildId;
NSInteger predecessorId = 0;
while (nextChildId > 0) {
if ([self.rootNode nodeFromID:nextChildId] != nil) { // already present in our tree ?
NSLog(@"Duplicate child with id %ld asked under folder with id %ld", (long)nextChildId, (long)node.nodeId);
return NO;
}
NSUInteger listIndex = [listOfFolderIds indexOfObject:@(nextChildId)];
if (listIndex == NSNotFound) {
NSLog(@"Cannot find child with id %ld for folder with id %ld", (long)nextChildId, (long)node.nodeId);
Expand Down

0 comments on commit a4c8c8f

Please sign in to comment.