Skip to content

Commit

Permalink
Merge branch 'release/1.12.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Oct 16, 2024
2 parents 383c51e + 0976089 commit 299be23
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Sources/CryptomatorCloudAccess/Box/BoxCloudProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public class BoxCloudProvider: CloudProvider {

private func convertStandardError(_ error: Error) -> Error {
switch error {
case let error as BoxAPIError where error.responseInfo.statusCode == 401:
case let error as BoxAPIError where (error.responseInfo.statusCode == 400 && error.responseInfo.rawBody?.contains("invalid_grant") == true) || error.responseInfo.statusCode == 401:
return CloudProviderError.unauthorized
case let error as BoxAPIError where error.responseInfo.statusCode == 404:
return CloudProviderError.itemNotFound
Expand Down
40 changes: 20 additions & 20 deletions Sources/CryptomatorCloudAccess/Dropbox/DropboxCloudProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public class DropboxCloudProvider: CloudProvider {
}
if let networkError = networkError {
CloudAccessDDLogDebug("DropboxCloudProvider: fetchItemMetadata(at: \(cloudPath.path)) failed with networkError: \(networkError)")
reject(self.convertRequestErrorToDropboxError(networkError))
reject(self.convertRequestError(networkError))
return
}
guard let result = result else {
Expand Down Expand Up @@ -241,7 +241,7 @@ public class DropboxCloudProvider: CloudProvider {
}
if let networkError = networkError {
CloudAccessDDLogDebug("DropboxCloudProvider: fetchItemList(at: \(cloudPath.path)) failed with networkError: \(networkError)")
reject(self.convertRequestErrorToDropboxError(networkError))
reject(self.convertRequestError(networkError))
return
}
guard let result = result else {
Expand Down Expand Up @@ -284,7 +284,7 @@ public class DropboxCloudProvider: CloudProvider {
if networkError.isBadInputError(), let errorContent = networkError.errorContent, errorContent.contains("invalidPageToken") {
reject(CloudProviderError.pageTokenInvalid)
} else {
reject(self.convertRequestErrorToDropboxError(networkError))
reject(self.convertRequestError(networkError))
}
return
}
Expand Down Expand Up @@ -331,7 +331,7 @@ public class DropboxCloudProvider: CloudProvider {
if networkError.isClientError(), case CocoaError.fileWriteFileExists = networkError.asClientError().nsError {
reject(CloudProviderError.itemAlreadyExists)
} else {
reject(self.convertRequestErrorToDropboxError(networkError))
reject(self.convertRequestError(networkError))
}
return
}
Expand Down Expand Up @@ -395,13 +395,13 @@ public class DropboxCloudProvider: CloudProvider {
guard let requestError = fileUrlsToRequestErrors[localURL] else {
return DropboxError.unexpectedError
}
return convertRequestErrorToDropboxError(requestError)
return convertRequestError(requestError)
} else if let finishBatchRouteError = finishBatchRouteError {
CloudAccessDDLogDebug("DropboxCloudProvider: handleBatchUploadMissingResult(for: \(localURL)) failed with finishBatchRouteError: \(finishBatchRouteError)")
return DropboxError.asyncPollError
} else if let finishBatchRequestError = finishBatchRequestError {
CloudAccessDDLogDebug("DropboxCloudProvider: handleBatchUploadMissingResult(for: \(localURL)) failed with finishBatchRequestError: \(finishBatchRequestError)")
return convertRequestErrorToDropboxError(finishBatchRequestError)
return convertRequestError(finishBatchRequestError)
} else {
CloudAccessDDLogDebug("DropboxCloudProvider: handleBatchUploadMissingResult(for: \(localURL)) failed with missingResult")
return DropboxError.missingResult
Expand Down Expand Up @@ -437,7 +437,7 @@ public class DropboxCloudProvider: CloudProvider {
}
if let networkError = networkError {
CloudAccessDDLogDebug("DropboxCloudProvider: uploadSmallFile(from: \(localURL), to: \(cloudPath.path), mode: \(mode?.description() ?? "nil")) failed with networkError: \(networkError)")
reject(self.convertRequestErrorToDropboxError(networkError))
reject(self.convertRequestError(networkError))
return
}
guard let result = result else {
Expand Down Expand Up @@ -473,7 +473,7 @@ public class DropboxCloudProvider: CloudProvider {
}
if let networkError = networkError {
CloudAccessDDLogDebug("DropboxCloudProvider: createFolder(at: \(cloudPath.path)) failed with networkError: \(networkError)")
reject(self.convertRequestErrorToDropboxError(networkError))
reject(self.convertRequestError(networkError))
return
}
guard let result = result else {
Expand Down Expand Up @@ -506,7 +506,7 @@ public class DropboxCloudProvider: CloudProvider {
}
if let networkError = networkError {
CloudAccessDDLogDebug("DropboxCloudProvider: deleteItem(at: \(cloudPath.path)) failed with networkError: \(networkError)")
reject(self.convertRequestErrorToDropboxError(networkError))
reject(self.convertRequestError(networkError))
return
}
guard let result = result else {
Expand Down Expand Up @@ -545,7 +545,7 @@ public class DropboxCloudProvider: CloudProvider {
}
if let networkError = networkError {
CloudAccessDDLogDebug("DropboxCloudProvider: moveItem(from: \(sourceCloudPath.path), to: \(targetCloudPath.path)) failed with networkError: \(networkError)")
reject(self.convertRequestErrorToDropboxError(networkError))
reject(self.convertRequestError(networkError))
return
}
guard let result = result else {
Expand Down Expand Up @@ -642,26 +642,26 @@ public class DropboxCloudProvider: CloudProvider {
}
}

func convertRequestErrorToDropboxError(_ error: DBRequestError) -> DropboxError {
func convertRequestError(_ error: DBRequestError) -> Error {
if error.isHttpError() {
return .httpError
return DropboxError.httpError
} else if error.isBadInputError() {
return .badInputError
return DropboxError.badInputError
} else if error.isAuthError() {
return .authError
return CloudProviderError.unauthorized
} else if error.isAccessError() {
return .accessError
return DropboxError.accessError
} else if error.isPathRootError() {
return .pathRootError
return DropboxError.pathRootError
} else if error.isRateLimitError() {
let rateLimitError = error.asRateLimitError()
return .rateLimitError(retryAfter: rateLimitError.backoff.intValue)
return DropboxError.rateLimitError(retryAfter: rateLimitError.backoff.intValue)
} else if error.isInternalServerError() {
return .internalServerError
return DropboxError.internalServerError
} else if error.isClientError() {
return .clientError
return DropboxError.clientError
} else {
return .unexpectedError
return DropboxError.unexpectedError
}
}
}
1 change: 0 additions & 1 deletion Sources/CryptomatorCloudAccess/Dropbox/DropboxError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public enum DropboxError: Error {

case httpError
case badInputError
case authError
case accessError
case pathRootError
case rateLimitError(retryAfter: Int)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2020 Skymatic GmbH. All rights reserved.
//

import AppAuthCore
import Foundation
import GoogleAPIClientForREST_Drive
import GRDB
Expand Down Expand Up @@ -532,7 +533,7 @@ public class GoogleDriveCloudProvider: CloudProvider {
CloudAccessDDLogDebug("GoogleDriveCloudProvider: executeQuery(\(query.requestID)) failed with error: \(error)")
if error.domain == NSURLErrorDomain, error.code == NSURLErrorNotConnectedToInternet || error.code == NSURLErrorCannotConnectToHost || error.code == NSURLErrorNetworkConnectionLost || error.code == NSURLErrorDNSLookupFailed || error.code == NSURLErrorResourceUnavailable || error.code == NSURLErrorInternationalRoamingOff {
reject(CloudProviderError.noInternetConnection)
} else if error.domain == kGTLRErrorObjectDomain, error.code == 401 || error.code == 403 {
} else if (error.domain == kGTLRErrorObjectDomain && (error.code == 401 || error.code == 403)) || (error.domain == OIDOAuthTokenErrorDomain && error.code == OIDErrorCodeOAuth.invalidGrant.rawValue) {
reject(CloudProviderError.unauthorized)
} else if error.domain == kGTLRErrorObjectDomain, error.code == 404 {
reject(CloudProviderError.itemNotFound)
Expand Down

0 comments on commit 299be23

Please sign in to comment.