Skip to content

Commit bf541c4

Browse files
[fix/recursive-fp-copy] Fix recursive copy in File Provider (#162)
* - OCVaultLocation: fix vfsItemID for cases where only .vfsNodeID is not set, but the node is still a virtual node (=> should have affected mostly drive-representing VFS nodes) * - OCBookmark: - add new .uuidString property (including caching) to avoid OCBookmark.uuid.uuidString calls - switch from bookmark.uuid.UUIDString to bookmark.uuidString across the codebase - OCSyncContext: - modernize syntax for private ivars - add new mechanism to add completion handler(s) to run after context actions have run - OCSyncActionCreateFolder: - add bookmarkUUID to placeholderItem - run the placeholder completion handler only after the folder item has been added to the database - OCVaultLocation: add debug description - OCVFSCore: add (and comment out) verbose debug logging for resolution
1 parent ecff6d3 commit bf541c4

16 files changed

Lines changed: 115 additions & 33 deletions

File tree

‎ownCloudSDK/Authentication/OCAuthenticationMethodOAuth2.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ - (void)_refreshTokenForConnection:(OCConnection *)connection availabilityHandle
777777
{
778778
__weak OCAuthenticationMethodOAuth2 *weakSelf = self;
779779

780-
OCLockRequest *lockRequest = [[OCLockRequest alloc] initWithResourceIdentifier:[NSString stringWithFormat:@"authentication-data-update:%@", connection.bookmark.uuid.UUIDString] acquiredHandler:^(NSError * _Nullable error, OCLock * _Nullable lock) {
780+
OCLockRequest *lockRequest = [[OCLockRequest alloc] initWithResourceIdentifier:[NSString stringWithFormat:@"authentication-data-update:%@", connection.bookmark.uuidString] acquiredHandler:^(NSError * _Nullable error, OCLock * _Nullable lock) {
781781
// Wait for exclusive lock on authentication data before performing the refresh
782782
[weakSelf __refreshTokenForConnection:connection availabilityHandler:^(NSError *error, BOOL authenticationIsAvailable) {
783783
// Invoke original availabilityHandler

‎ownCloudSDK/Bookmark/OCBookmark.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ NS_ASSUME_NONNULL_BEGIN
4242
@interface OCBookmark : NSObject <NSSecureCoding, NSCopying>
4343

4444
@property(readonly) OCBookmarkUUID uuid; //!< UUID uniquely identifying the bookmark
45+
@property(readonly,nonatomic) OCBookmarkUUIDString uuidString; //!< String version of .uuid (cached!)
4546

4647
@property(strong,nullable) NSString *name; //!< Name of the server
4748
@property(strong,nullable) NSURL *url; //!< URL to use to connect to the server

‎ownCloudSDK/Bookmark/OCBookmark.m‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#import <UIKit/UIKit.h>
2929
#endif /* TARGET_OS_IOS */
3030

31-
@interface OCBookmark ()
31+
@implementation OCBookmark
3232
{
3333
OCIPCNotificationName _coreUpdateNotificationName;
3434
OCIPCNotificationName _bookmarkAuthUpdateNotificationName;
@@ -40,10 +40,9 @@ @interface OCBookmark ()
4040
NSString *_lastUsername;
4141

4242
NSString *_lastDescription;
43-
}
44-
@end
4543

46-
@implementation OCBookmark
44+
OCBookmarkUUIDString _uuidString;
45+
}
4746

4847
@synthesize uuid = _uuid;
4948

@@ -119,6 +118,17 @@ - (NSData *)bookmarkData
119118
return ([NSKeyedArchiver archivedDataWithRootObject:self]);
120119
}
121120

121+
#pragma mark - UUID string
122+
- (OCBookmarkUUIDString)uuidString
123+
{
124+
if (_uuidString == nil)
125+
{
126+
_uuidString = _uuid.UUIDString;
127+
}
128+
129+
return (_uuidString);
130+
}
131+
122132
#pragma mark - Keychain access
123133
- (NSData *)authenticationData
124134
{
@@ -462,6 +472,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder
462472
if ((self = [self init]) != nil)
463473
{
464474
_uuid = [decoder decodeObjectOfClass:NSUUID.class forKey:@"uuid"];
475+
_uuidString = nil;
465476

466477
_name = [decoder decodeObjectOfClass:NSString.class forKey:@"name"];
467478
_url = [decoder decodeObjectOfClass:NSURL.class forKey:@"url"];

‎ownCloudSDK/Connection/OCConnection+Upload.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ - (OCProgress *)_continueTusJob:(OCTUSJob *)tusJob lastTask:(NSString *)lastTask
322322
}
323323

324324
tusProgress = [[OCProgress alloc] initWithPath:((self.bookmark.uuid != nil) ?
325-
@[ OCProgressPathElementIdentifierCoreRoot, self.bookmark.uuid.UUIDString, OCProgressPathElementIdentifierCoreConnectionPath, tusJob.trackingID ] :
325+
@[ OCProgressPathElementIdentifierCoreRoot, self.bookmark.uuidString, OCProgressPathElementIdentifierCoreConnectionPath, tusJob.trackingID ] :
326326
@[])
327327
progress:actionProgress];
328328
}

‎ownCloudSDK/Connection/OCConnection.m‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ - (instancetype)initWithBookmark:(OCBookmark *)bookmark
473473
{
474474
if ((self = [super init]) != nil)
475475
{
476-
_partitionID = bookmark.uuid.UUIDString;
476+
_partitionID = bookmark.uuidString;
477477

478478
self.bookmark = bookmark;
479479

@@ -2076,6 +2076,13 @@ - (void)_handleRetrieveItemListAtPathResult:(OCHTTPRequest *)request error:(NSEr
20762076
{
20772077
event.error = errors.firstObject;
20782078
}
2079+
else if (items != nil)
2080+
{
2081+
OCBookmarkUUIDString bookmarkUUIDString = self.bookmark.uuidString;
2082+
for (OCItem *item in items) {
2083+
item.bookmarkUUID = bookmarkUUIDString;
2084+
}
2085+
}
20792086

20802087
switch (eventType)
20812088
{

‎ownCloudSDK/Core/ItemList/OCCore+ItemList.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1957,7 +1957,7 @@ - (void)_coordinatedScanForChanges
19571957

19581958
if (_scanForChangesLockRequest == nil) // do not make second request if another one is already in progress - do nothing in that case
19591959
{
1960-
_scanForChangesLockRequest = [[OCLockRequest alloc] initWithResourceIdentifier:[OCLockResourceIdentifierCoreUpdateScan stringByAppendingFormat:@":%@",_bookmark.uuid.UUIDString] tryAcquireHandler:^(NSError * _Nullable error, OCLock * _Nullable lock) {
1960+
_scanForChangesLockRequest = [[OCLockRequest alloc] initWithResourceIdentifier:[OCLockResourceIdentifierCoreUpdateScan stringByAppendingFormat:@":%@",_bookmark.uuidString] tryAcquireHandler:^(NSError * _Nullable error, OCLock * _Nullable lock) {
19611961
OCCore *core;
19621962

19631963
if ((core = weakSelf) != nil)

‎ownCloudSDK/Core/ItemPolicies/OCCore+ItemPolicies.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ - (void)_updatePolicyProcessors
441441
#pragma mark - IPC
442442
- (OCIPCNotificationName)itemPoliciesChangedNotificationName
443443
{
444-
return ([OCIPCNotificationNameItemPoliciesChangedPrefix stringByAppendingFormat:@".%@", self.bookmark.uuid.UUIDString]);
444+
return ([OCIPCNotificationNameItemPoliciesChangedPrefix stringByAppendingFormat:@".%@", self.bookmark.uuidString]);
445445
}
446446

447447
- (void)setupItemPolicies

‎ownCloudSDK/Core/OCCore.m‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ - (instancetype)initWithBookmark:(OCBookmark *)bookmark
257257

258258
_preferredChecksumAlgorithm = OCChecksumAlgorithmIdentifierSHA1;
259259

260-
_eventHandlerIdentifier = [@"OCCore-" stringByAppendingString:_bookmark.uuid.UUIDString];
260+
_eventHandlerIdentifier = [@"OCCore-" stringByAppendingString:_bookmark.uuidString];
261261
_pendingThumbnailRequests = [NSMutableDictionary new];
262262

263263
_ipNotificationCenter = OCIPNotificationCenter.sharedNotificationCenter;
@@ -318,7 +318,7 @@ - (instancetype)initWithBookmark:(OCBookmark *)bookmark
318318
}]);
319319
}];
320320

321-
_activityManager = [[OCActivityManager alloc] initWithUpdateNotificationName:[@"OCCore.ActivityUpdate." stringByAppendingString:_bookmark.uuid.UUIDString]];
321+
_activityManager = [[OCActivityManager alloc] initWithUpdateNotificationName:[@"OCCore.ActivityUpdate." stringByAppendingString:_bookmark.uuidString]];
322322
_publishedActivitySyncRecordIDs = [NSMutableSet new];
323323

324324
_itemPolicies = [NSMutableArray new];

‎ownCloudSDK/Core/Resources/Sources/OCResourceSource.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ - (instancetype)initWithCore:(OCCore *)core
2929
if ((self = [super init]) != nil)
3030
{
3131
_core = core;
32-
_eventHandlerIdentifier = [NSString stringWithFormat:@"%@-%@-%@", NSStringFromClass(self.class), self.identifier, core.bookmark.uuid.UUIDString];
32+
_eventHandlerIdentifier = [NSString stringWithFormat:@"%@-%@-%@", NSStringFromClass(self.class), self.identifier, core.bookmark.uuidString];
3333
}
3434

3535
return (self);

‎ownCloudSDK/Core/Sync/Actions/CreateFolder/OCSyncActionCreateFolder.m‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ - (instancetype)initWithParentItem:(OCItem *)parentItem folderName:(NSString *)f
3838

3939
if ((placeholderItem = [OCItem placeholderItemOfType:OCItemTypeCollection]) != nil)
4040
{
41+
placeholderItem.bookmarkUUID = self.core.bookmark.uuidString;
4142
placeholderItem.parentFileID = parentItem.fileID;
4243
placeholderItem.parentLocalID = parentItem.localID;
4344
placeholderItem.driveID = parentItem.driveID;
@@ -73,7 +74,13 @@ - (void)preflightWithContext:(OCSyncContext *)syncContext
7374

7475
if ((placeholderCompletionHandler = self.ephermalParameters[OCCoreOptionPlaceholderCompletionHandler]) != nil)
7576
{
76-
placeholderCompletionHandler(nil, _placeholderItem);
77+
OCItem *placeholderItem = _placeholderItem;
78+
79+
// Run completion handler only after database updates have been performed, so the returned item is immediately usable
80+
[syncContext addContextActionsCompletionHandler:^{
81+
placeholderCompletionHandler(nil, placeholderItem);
82+
}];
83+
7784
self.ephermalParameters = nil;
7885
}
7986

0 commit comments

Comments
 (0)