From 68084314180bcdd86c89d346baab44030483420b Mon Sep 17 00:00:00 2001 From: Felix Schwarz Date: Thu, 31 Jan 2019 11:05:17 +0100 Subject: [PATCH] - Single item queries: take into account that if items are moved on the server, and they haven't come into view at their new location yet, they may temporarily appear as removed --- ownCloudSDK/Core/OCCore+ItemUpdates.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ownCloudSDK/Core/OCCore+ItemUpdates.m b/ownCloudSDK/Core/OCCore+ItemUpdates.m index 2f42c7f5..3d237ebb 100644 --- a/ownCloudSDK/Core/OCCore+ItemUpdates.m +++ b/ownCloudSDK/Core/OCCore+ItemUpdates.m @@ -424,7 +424,8 @@ - (void)performUpdatesForAddedItems:(nullable NSArray *)addedItems if (query.queryItem != nil) { // Only update queries that have already gone through their complete, initial content update - if (query.state == OCQueryStateIdle) + if ((query.state == OCQueryStateIdle) || + (query.state == OCQueryStateTargetRemoved)) // An item could appear removed temporarily when it was moved on the server and the item has not yet been seen by the core in its new location { OCPath queryItemPath = query.queryItem.path; OCLocalID queryItemLocalID = query.queryItem.localID; @@ -434,10 +435,12 @@ - (void)performUpdatesForAddedItems:(nullable NSArray *)addedItems { if ((resultItem = addedItemList.itemsByPath[queryItemPath]) != nil) { + query.state = OCQueryStateIdle; query.fullQueryResults = [NSMutableArray arrayWithObject:resultItem]; } else if ((resultItem = addedItemList.itemsByLocalID[queryItemLocalID]) != nil) { + query.state = OCQueryStateIdle; query.fullQueryResults = [NSMutableArray arrayWithObject:resultItem]; } } @@ -446,10 +449,12 @@ - (void)performUpdatesForAddedItems:(nullable NSArray *)addedItems { if ((resultItem = updatedItemList.itemsByPath[queryItemPath]) != nil) { + query.state = OCQueryStateIdle; query.fullQueryResults = [NSMutableArray arrayWithObject:resultItem]; } else if ((resultItem = updatedItemList.itemsByLocalID[queryItemLocalID]) != nil) { + query.state = OCQueryStateIdle; query.fullQueryResults = [NSMutableArray arrayWithObject:resultItem]; } } @@ -458,8 +463,8 @@ - (void)performUpdatesForAddedItems:(nullable NSArray *)addedItems { if ((removedItemList.itemsByPath[queryItemPath] != nil) || (removedItemList.itemsByLocalID[queryItemLocalID] != nil)) { - query.fullQueryResults = [NSMutableArray new]; query.state = OCQueryStateTargetRemoved; + query.fullQueryResults = [NSMutableArray new]; } } }