Skip to content

Commit

Permalink
Merge branch 'release/1.11.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Sep 16, 2024
2 parents 92e6e3d + f5075bb commit 2d84440
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 23 deletions.
6 changes: 3 additions & 3 deletions CryptomatorCloudAccess.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1890,10 +1890,10 @@
};
B3C72B752BFC798A006F8218 /* XCRemoteSwiftPackageReference "box-swift-sdk-gen" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/box/box-swift-sdk-gen.git";
repositoryURL = "https://github.com/tobihagemann/box-swift-sdk-gen.git";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.5.0;
kind = exactVersion;
version = "0.5.0-cryptomator";
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "9cadc7a70613b038fe8d97d191b9a6f48d09309fa0636f36dfa1ef6376591ebc",
"originHash" : "1e544db849a8e8bec5142a55d1c8c095e3af91fce1264266393ab47c4271d671",
"pins" : [
{
"identity" : "appauth-ios",
Expand Down Expand Up @@ -31,10 +31,10 @@
{
"identity" : "box-swift-sdk-gen",
"kind" : "remoteSourceControl",
"location" : "https://github.com/box/box-swift-sdk-gen.git",
"location" : "https://github.com/tobihagemann/box-swift-sdk-gen.git",
"state" : {
"revision" : "a6b5793ab4053f9b55b840245ad07c9e3fdae344",
"version" : "0.5.0"
"revision" : "b2bb9db3b4fc5e86807f3c5043bedcab9fdf48f7",
"version" : "0.5.0-cryptomator"
}
},
{
Expand Down
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
{
"identity" : "box-swift-sdk-gen",
"kind" : "remoteSourceControl",
"location" : "https://github.com/box/box-swift-sdk-gen.git",
"location" : "https://github.com/tobihagemann/box-swift-sdk-gen.git",
"state" : {
"revision" : "a6b5793ab4053f9b55b840245ad07c9e3fdae344",
"version" : "0.5.0"
"revision" : "b2bb9db3b4fc5e86807f3c5043bedcab9fdf48f7",
"version" : "0.5.0-cryptomator"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/AzureAD/microsoft-authentication-library-for-objc.git", .upToNextMinor(from: "1.3.0")),
.package(url: "https://github.com/aws-amplify/aws-sdk-ios-spm.git", .upToNextMinor(from: "2.34.0")),
.package(url: "https://github.com/box/box-swift-sdk-gen.git", .upToNextMinor(from: "0.5.0")),
.package(url: "https://github.com/cryptomator/cryptolib-swift.git", .upToNextMinor(from: "1.1.0")),
.package(url: "https://github.com/CocoaLumberjack/CocoaLumberjack.git", .upToNextMinor(from: "3.8.0")),
.package(url: "https://github.com/google/google-api-objectivec-client-for-rest.git", .upToNextMinor(from: "3.4.0")),
Expand All @@ -43,6 +42,7 @@ let package = Package(
.package(url: "https://github.com/phil1995/dropbox-sdk-obj-c-spm.git", .upToNextMinor(from: "7.2.0")),
.package(url: "https://github.com/phil1995/msgraph-sdk-objc-spm.git", .upToNextMinor(from: "1.0.0")),
.package(url: "https://github.com/phil1995/msgraph-sdk-objc-models-spm.git", .upToNextMinor(from: "1.3.0")),
.package(url: "https://github.com/tobihagemann/box-swift-sdk-gen.git", exact: "0.5.0-cryptomator"),
.package(url: "https://github.com/tobihagemann/JOSESwift.git", exact: "2.4.1-cryptomator")
],
targets: [
Expand Down
15 changes: 3 additions & 12 deletions Sources/CryptomatorCloudAccess/Box/BoxCloudProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,12 @@ public class BoxCloudProvider: CloudProvider {
let pendingPromise = Promise<CloudItemMetadata>.pending()
_Concurrency.Task {
do {
guard let fileStream = InputStream(url: localURL) else {
throw CloudProviderError.itemNotFound
}
let requestBody = UploadFileRequestBody(
attributes: UploadFileRequestBodyAttributesField(
name: cloudPath.lastPathComponent,
parent: UploadFileRequestBodyAttributesParentField(id: parentItem.identifier)
),
file: fileStream
fileURL: localURL
)
let files = try await client.uploads.uploadFile(requestBody: requestBody)
guard let file = files.entries?.first else {
Expand All @@ -274,12 +271,9 @@ public class BoxCloudProvider: CloudProvider {
let pendingPromise = Promise<CloudItemMetadata>.pending()
_Concurrency.Task {
do {
guard let fileStream = InputStream(url: localURL) else {
throw CloudProviderError.itemNotFound
}
let requestBody = UploadFileVersionRequestBody(
attributes: UploadFileVersionRequestBodyAttributesField(name: cloudPath.lastPathComponent),
file: fileStream
fileURL: localURL
)
let files = try await client.uploads.uploadFileVersion(fileId: existingItem.identifier, requestBody: requestBody)
guard let file = files.entries?.first else {
Expand Down Expand Up @@ -329,14 +323,11 @@ public class BoxCloudProvider: CloudProvider {
}

private func uploadLargeFile(for uploadSession: UploadSession, from localURL: URL, to cloudPath: CloudPath, fileSize: Int) async throws -> CloudItemMetadata {
guard let fileStream = InputStream(url: localURL) else {
throw CloudProviderError.itemNotFound
}
guard let uploadPartUrl = uploadSession.sessionEndpoints?.uploadPart, let commitUrl = uploadSession.sessionEndpoints?.commit, let partSize = uploadSession.partSize else {
throw BoxSDKError(message: "Failed to retrieve upload session data")
}
let fileHash = Hash(algorithm: .sha1)
let chunksIterator = Utils.iterateChunks(stream: fileStream, chunkSize: partSize, fileSize: Int64(fileSize))
let chunksIterator = Utils.iterateChunks(fileURL: localURL, chunkSize: partSize, fileSize: Int64(fileSize))
let results = try await Utils.reduceIterator(iterator: chunksIterator, reducer: client.chunkedUploads.reducer, initialValue: PartAccumulator(lastIndex: -1, parts: [], fileSize: Int64(fileSize), uploadPartUrl: uploadPartUrl, fileHash: fileHash))
let sha1 = await fileHash.digestHash(encoding: "base64")
let digest = "\("sha=")\(sha1)"
Expand Down

0 comments on commit 2d84440

Please sign in to comment.