Skip to content

Commit

Permalink
[milestone/11.10] SDK release version 11.10 (#96)
Browse files Browse the repository at this point in the history
* [feature/openssl-1.1.1] Migration to OpenSSL 1.1.1 (#95)

- migrated code to new OpenSSL 1.1.1 API
- using OpenSSL package via SwiftPM

* - remove OpenSSL 1.0.x includes, build scripts and binaries

* - NSError+OCNetworkFailure: add .isNetworkTimeoutError convenience property
- NSError+OCError: add new error for request timeouts
- OCConnection
	- make better use of the error parameter in HTTP response handling to actions
	- increase timeout for COPY requests to 10 minutes
- OCSyncActionCopyMove: improve error handling for HTTP timeouts
- OCHostSimulator+Builtin: add new "action-timeout-simulator" that responds to action requests with timeout errors

* - OCSyncActionCopyMove/Localizable.strings: add missing localizations

Co-authored-by: Matthias Hühne <mhuehne@owncloud.com>
  • Loading branch information
felix-schwarz and hosy committed May 16, 2022
1 parent d2fa235 commit 26fbb1e
Show file tree
Hide file tree
Showing 96 changed files with 413 additions and 40,143 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 11.10 version
- upgrade OpenSSL to 1.1.1 and switch from bundled version to SwiftPM (#95)
- NSError+OCNetworkFailure: add .isNetworkTimeoutError convenience property
- NSError+OCError: add new error for request timeouts
- OCConnection
- make better use of the error parameter in HTTP response handling to actions
- increase timeout for COPY requests to 10 minutes
- OCSyncActionCopyMove: improve error handling for HTTP timeouts
- OCHostSimulator+Builtin: add new "action-timeout-simulator" that responds to action requests with timeout errors

## 11.9.1 version
- OCAuthenticationMethodOAuth2/OIDC: no longer treat network errors during token refresh as permanently failed refresh
- OCHostSimulator: add auth-race-condition host simulator, to test handling of race conditions in Authorization
Expand Down
181 changes: 88 additions & 93 deletions ownCloudSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface NSError (OCNetworkFailure)

@property(readonly,nonatomic) BOOL isNetworkFailureError;
@property(readonly,nonatomic) BOOL isNetworkTimeoutError;

@end

Expand Down
5 changes: 5 additions & 0 deletions ownCloudSDK/Categories/Foundation/NSError+OCNetworkFailure.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ - (BOOL)isNetworkFailureError
));
}

- (BOOL)isNetworkTimeoutError
{
return ([self.domain isEqual:NSURLErrorDomain] && (self.code == NSURLErrorTimedOut));
}

@end
56 changes: 49 additions & 7 deletions ownCloudSDK/Connection/OCConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#import "NSURL+OCURLNormalization.h"
#import "OCDAVRawResponse.h"
#import "OCBookmarkManager.h"
#import "NSError+OCNetworkFailure.h"

// Imported to use the identifiers in OCConnectionPreferredAuthenticationMethodIDs only
#import "OCAuthenticationMethodOpenIDConnect.h"
Expand Down Expand Up @@ -2138,7 +2139,11 @@ - (void)_handleDownloadItemResult:(OCHTTPRequest *)request error:(NSError *)erro
}
else
{
if (request.error != nil)
if (error != nil)
{
event.error = error;
}
else if (request.error != nil)
{
event.error = request.error;
}
Expand Down Expand Up @@ -2323,7 +2328,11 @@ - (void)_handleUpdateItemResult:(OCHTTPRequest *)request error:(NSError *)error

if ((event = [OCEvent eventForEventTarget:request.eventTarget type:OCEventTypeUpdate uuid:request.identifier attributes:nil]) != nil)
{
if (request.error != nil)
if (error != nil)
{
event.error = error;
}
else if (request.error != nil)
{
event.error = request.error;
}
Expand Down Expand Up @@ -2436,7 +2445,11 @@ - (void)_handleCreateFolderResult:(OCHTTPRequest *)request error:(NSError *)erro

if ((event = [OCEvent eventForEventTarget:request.eventTarget type:OCEventTypeCreateFolder uuid:request.identifier attributes:nil]) != nil)
{
if (request.error != nil)
if (error != nil)
{
event.error = error;
}
else if (request.error != nil)
{
event.error = request.error;
}
Expand Down Expand Up @@ -2574,6 +2587,12 @@ - (OCProgress *)_copyMoveMethod:(OCHTTPMethod)requestMethod type:(OCEventType)ev
};
request.priority = NSURLSessionTaskPriorityHigh;

if ([requestMethod isEqual:OCHTTPMethodCOPY])
{
// Extend timeout to 10 minutes for COPY
request.customTimeout = @(10 * 60.0);
}

request.forceCertificateDecisionDelegation = YES;

[request setValue:[destinationURL absoluteString] forHeaderField:OCHTTPHeaderFieldNameDestination];
Expand Down Expand Up @@ -2608,7 +2627,18 @@ - (void)_handleCopyMoveItemResult:(OCHTTPRequest *)request error:(NSError *)erro

if ((event = [OCEvent eventForEventTarget:request.eventTarget type:eventType uuid:request.identifier attributes:nil]) != nil)
{
if (request.error != nil)
if (error != nil)
{
if (error.isNetworkTimeoutError)
{
event.error = OCError(OCErrorRequestTimeout);
}
else
{
event.error = error;
}
}
else if (request.error != nil)
{
event.error = request.error;
}
Expand Down Expand Up @@ -2741,7 +2771,11 @@ - (void)_handleDeleteItemResult:(OCHTTPRequest *)request error:(NSError *)error

if ((event = [OCEvent eventForEventTarget:request.eventTarget type:OCEventTypeDelete uuid:request.identifier attributes:nil]) != nil)
{
if (request.error != nil)
if (error != nil)
{
event.error = error;
}
else if (request.error != nil)
{
event.error = request.error;
}
Expand Down Expand Up @@ -2953,7 +2987,11 @@ - (void)_handleRetrieveThumbnailResult:(OCHTTPRequest *)request error:(NSError *

if ((event = [OCEvent eventForEventTarget:request.eventTarget type:OCEventTypeRetrieveThumbnail uuid:request.identifier attributes:nil]) != nil)
{
if (request.error != nil)
if (error != nil)
{
event.error = error;
}
else if (request.error != nil)
{
event.error = request.error;
}
Expand Down Expand Up @@ -3057,7 +3095,11 @@ - (void)_handleFilterFilesResult:(OCHTTPRequest *)request error:(NSError *)error

if ((event = [OCEvent eventForEventTarget:request.eventTarget type:OCEventTypeFilterFiles uuid:request.identifier attributes:nil]) != nil)
{
if (request.error != nil)
if (error != nil)
{
event.error = error;
}
else if (request.error != nil)
{
event.error = request.error;
}
Expand Down
141 changes: 77 additions & 64 deletions ownCloudSDK/Core/Sync/Actions/CopyMove/OCSyncActionCopyMove.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#import "OCSyncActionCopyMove.h"
#import "NSError+OCNetworkFailure.h"

@interface OCSyncActionCopyMove ()
{
Expand Down Expand Up @@ -373,103 +374,115 @@ - (OCCoreSyncInstruction)handleResultWithContext:(OCSyncContext *)syncContext
[syncContext transitionToState:OCSyncRecordStateCompleted withWaitConditions:nil];
resultInstruction = OCCoreSyncInstructionDeleteLast;
}
else if (event.error.isOCError)
else if (event.error.isOCError || ((event.error != nil) && !event.error.isNetworkFailureError))
{
NSString *issueTitle=nil, *issueDescription=nil;
OCPath targetPath;
BOOL fallbackErrorMessage = YES;

targetPath = [self.targetParentItem.path stringByAppendingString:self.targetName];

switch (event.error.code)
{
case OCErrorItemOperationForbidden:
issueTitle = OCLocalizedString(@"Operation forbidden",nil);
if (isCopy)
{
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"%@ can't be copied to %@.",nil), self.localItem.path, targetPath];
}
else
{
if (self.isRename)
if (event.error.isOCError)
{
fallbackErrorMessage = NO;

switch (event.error.code)
{
case OCErrorItemOperationForbidden:
issueTitle = OCLocalizedString(@"Operation forbidden",nil);
if (isCopy)
{
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"%@ couldn't be renamed to %@.",nil), self.localItem.name, self.targetName];
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"%@ can't be copied to %@.",nil), self.localItem.path, targetPath];
}
else
{
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"%@ can't be moved to %@.",nil), self.localItem.path, targetPath];
if (self.isRename)
{
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"%@ can't be renamed to %@.",nil), self.localItem.name, self.targetName];
}
else
{
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"%@ can't be moved to %@.",nil), self.localItem.path, targetPath];
}
}
}
break;
break;

case OCErrorItemNotFound:
issueTitle = [NSString stringWithFormat:OCLocalizedString(@"%@ not found",nil), self.localItem.name];
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"%@ wasn't found at %@.",nil), self.localItem.name, [self.localItem.path stringByDeletingLastPathComponent]];
break;
case OCErrorItemNotFound:
issueTitle = [NSString stringWithFormat:OCLocalizedString(@"%@ not found",nil), self.localItem.name];
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"%@ wasn't found at %@.",nil), self.localItem.name, [self.localItem.path stringByDeletingLastPathComponent]];
break;

case OCErrorItemDestinationNotFound:
issueTitle = [NSString stringWithFormat:OCLocalizedString(@"%@ not found",nil), [[targetPath stringByDeletingLastPathComponent] lastPathComponent]];
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"The target directory %@ doesn't seem to exist.",nil), [targetPath stringByDeletingLastPathComponent]];
break;
case OCErrorItemDestinationNotFound:
issueTitle = [NSString stringWithFormat:OCLocalizedString(@"%@ not found",nil), [[targetPath stringByDeletingLastPathComponent] lastPathComponent]];
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"The target directory %@ doesn't seem to exist.",nil), [targetPath stringByDeletingLastPathComponent]];
break;

case OCErrorItemAlreadyExists:
issueTitle = [NSString stringWithFormat:OCLocalizedString(@"%@ already exists",nil), self.targetName];
if (isCopy)
{
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"Couldn't copy %@ to %@, because an item called %@ already exists there.",nil), self.localItem.name, targetPath, self.targetName];
}
else
{
if (self.isRename)
case OCErrorItemAlreadyExists:
issueTitle = [NSString stringWithFormat:OCLocalizedString(@"%@ already exists",nil), self.targetName];
if (isCopy)
{
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"Couldn't rename %@ to %@, because another item with that name already exists.",nil), self.localItem.name, self.targetName];
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"Couldn't copy %@ to %@, because an item called %@ already exists there.",nil), self.localItem.name, targetPath, self.targetName];
}
else
{
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"Couldn't move %@ to %@, because an item called %@ already exists there.",nil), self.localItem.name, targetPath, self.targetName];
if (self.isRename)
{
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"Couldn't rename %@ to %@, because another item with that name already exists.",nil), self.localItem.name, self.targetName];
}
else
{
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"Couldn't move %@ to %@, because an item called %@ already exists there.",nil), self.localItem.name, targetPath, self.targetName];
}
}
}
break;
break;

case OCErrorItemInsufficientPermissions:
issueTitle = OCLocalizedString(@"Insufficient permissions",nil);
if (isCopy)
{
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"%@ can't be copied to %@.",nil), self.localItem.path, targetPath];
}
else
{
if (self.isRename)
case OCErrorItemInsufficientPermissions:
issueTitle = OCLocalizedString(@"Insufficient permissions",nil);
if (isCopy)
{
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"%@ couldn't be renamed to %@.",nil), self.localItem.name, self.targetName];
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"%@ can't be copied to %@.",nil), self.localItem.path, targetPath];
}
else
{
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"%@ can't be moved to %@.",nil), self.localItem.path, targetPath];
if (self.isRename)
{
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"%@ couldn't be renamed to %@.",nil), self.localItem.name, self.targetName];
}
else
{
issueDescription = [NSString stringWithFormat:OCLocalizedString(@"%@ can't be moved to %@.",nil), self.localItem.path, targetPath];
}
}
}
break;
break;

default:
fallbackErrorMessage = YES;
break;
}
}

default:
if (isCopy)
if (fallbackErrorMessage)
{
if (isCopy)
{
issueTitle = [NSString stringWithFormat:OCLocalizedString(@"Error copying %@",nil), self.localItem.path];
}
else
{
if (self.isRename)
{
issueTitle = [NSString stringWithFormat:OCLocalizedString(@"Error copying %@",nil), self.localItem.path];
issueTitle = [NSString stringWithFormat:OCLocalizedString(@"Error renaming %@",nil), self.localItem.name];
}
else
{
if (self.isRename)
{
issueTitle = [NSString stringWithFormat:OCLocalizedString(@"Error renaming %@",nil), self.localItem.name];
}
else
{
issueTitle = [NSString stringWithFormat:OCLocalizedString(@"Error moving %@",nil), self.localItem.path];
}
issueTitle = [NSString stringWithFormat:OCLocalizedString(@"Error moving %@",nil), self.localItem.path];
}
issueDescription = event.error.localizedDescription;
break;
}

issueDescription = event.error.localizedDescription;
}

if (issueDescription != nil)
if ((issueDescription != nil) && event.error.isOCError)
{
event.error = OCErrorWithDescription(event.error.code, issueDescription);
}
Expand Down
4 changes: 3 additions & 1 deletion ownCloudSDK/Errors/NSError+OCError.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ typedef NS_ENUM(NSUInteger, OCError)
OCErrorLockInvalidated, //!< Lock invalidated.

OCErrorWebFingerLacksServerInstanceRelation, //!< Web finger response lacks server instance relation.
OCErrorUnknownUser //!< Unknown user
OCErrorUnknownUser, //!< Unknown user

OCErrorRequestTimeout //!< Request timed out
};

@class OCIssue;
Expand Down
4 changes: 4 additions & 0 deletions ownCloudSDK/Errors/NSError+OCError.m
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ + (id)provideUserInfoValueForOCError:(NSError *)error userInfoKey:(NSErrorUserIn
case OCErrorUnknownUser:
unlocalizedString = @"Unknown user";
break;

case OCErrorRequestTimeout:
unlocalizedString = @"Request timed out";
break;
}
}
}
Expand Down
Loading

0 comments on commit 26fbb1e

Please sign in to comment.