Skip to content

Commit

Permalink
Fixed build error, cleaned up BoxCredential and BoxItem
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Aug 20, 2024
1 parent cb72af7 commit 86d3564
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 37 deletions.
19 changes: 3 additions & 16 deletions Sources/CryptomatorCloudAccess/Box/BoxCloudProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -746,35 +746,22 @@ public class BoxCloudProvider: CloudProvider {
let name = metadata.name ?? ""
let itemType = CloudItemType.file
let size = metadata.size.map { Int($0) }
let dateString = metadata.modifiedAt

let dateFormatter = ISO8601DateFormatter()

let lastModifiedDate = dateString != nil ? dateFormatter.date(from: dateString!) : nil
let lastModifiedDate = metadata.modifiedAt
return CloudItemMetadata(name: name, cloudPath: cloudPath, itemType: itemType, lastModifiedDate: lastModifiedDate, size: size)
}

private func convertToCloudItemMetadata(_ metadata: Folder, at cloudPath: CloudPath) -> CloudItemMetadata {
let name = metadata.name ?? ""
let itemType = CloudItemType.folder
let dateString = metadata.modifiedAt

let dateFormatter = ISO8601DateFormatter()

let lastModifiedDate = dateString != nil ? dateFormatter.date(from: dateString!) : nil

let lastModifiedDate = metadata.modifiedAt
return CloudItemMetadata(name: name, cloudPath: cloudPath, itemType: itemType, lastModifiedDate: lastModifiedDate, size: nil)
}

private func convertToCloudItemMetadata(_ metadata: FileFull, at cloudPath: CloudPath) -> CloudItemMetadata {
let name = metadata.name ?? ""
let itemType = CloudItemType.file
let size = metadata.size.map { Int($0) }
let dateString = metadata.modifiedAt

let dateFormatter = ISO8601DateFormatter()

let lastModifiedDate = dateString != nil ? dateFormatter.date(from: dateString!) : nil
let lastModifiedDate = metadata.modifiedAt
return CloudItemMetadata(name: name, cloudPath: cloudPath, itemType: itemType, lastModifiedDate: lastModifiedDate, size: size)
}

Expand Down
7 changes: 0 additions & 7 deletions Sources/CryptomatorCloudAccess/Box/BoxCredential.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Promises

public enum BoxCredentialErrors: Error {
case noUsername
case authenticationFailed
}

public class BoxCredential {
Expand All @@ -27,7 +26,6 @@ public class BoxCredential {

public func deauthenticate() -> Promise<Void> {
let pendingPromise = Promise<Void>.pending()

_Concurrency.Task {
do {
let networkSession = NetworkSession()
Expand All @@ -37,13 +35,11 @@ public class BoxCredential {
pendingPromise.reject(error)
}
}

return pendingPromise
}

public func getUsername() -> Promise<String> {
let pendingPromise = Promise<String>.pending()

_Concurrency.Task {
do {
let user = try await client.users.getUserMe()
Expand All @@ -56,13 +52,11 @@ public class BoxCredential {
pendingPromise.reject(error)
}
}

return pendingPromise
}

public func getUserId() -> Promise<String> {
let pendingPromise = Promise<String>.pending()

_Concurrency.Task {
do {
let user = try await client.users.getUserMe()
Expand All @@ -71,7 +65,6 @@ public class BoxCredential {
pendingPromise.reject(error)
}
}

return pendingPromise
}
}
14 changes: 0 additions & 14 deletions Sources/CryptomatorCloudAccess/Box/BoxItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,6 @@ struct BoxItem: Decodable, FetchableRecord, TableRecord, Equatable {
}

extension BoxItem {
// TODO: Must be checked whether this init is needed at all

init(cloudPath: CloudPath, folderItem: FileOrFolderOrWebLink) throws {
switch folderItem {
case let .file(file):
self.init(cloudPath: cloudPath, file: file)
case let .folder(folder):
self.init(cloudPath: cloudPath, folder: folder)
// Weblinks are currently not supported, if required they can be added later.
case .webLink:
throw BoxError.unexpectedContent
}
}

init(cloudPath: CloudPath, file: FileBase) {
self.cloudPath = cloudPath
self.identifier = file.id
Expand Down

0 comments on commit 86d3564

Please sign in to comment.