Skip to content

Commit

Permalink
Merge branch 'release/1.11.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Sep 14, 2024
2 parents ff48ad0 + 67192ac commit 92e6e3d
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,25 @@ public class OneDriveCloudProvider: CloudProvider {
private let tmpDirURL: URL
private let maxPageSize: Int

init(credential: OneDriveCredential, maxPageSize: Int = .max, urlSessionConfiguration: URLSessionConfiguration) throws {
init(credential: OneDriveCredential, maxPageSize: Int = .max, urlSessionConfiguration: URLSessionConfiguration, unauthenticatedURLSessionConfiguration: URLSessionConfiguration) throws {
self.client = MSClientFactory.createHTTPClient(with: credential.authProvider, andSessionConfiguration: urlSessionConfiguration)
self.unauthenticatedClient = MSClientFactory.createUnauthenticatedHTTPClient(with: urlSessionConfiguration)
self.unauthenticatedClient = MSClientFactory.createUnauthenticatedHTTPClient(with: unauthenticatedURLSessionConfiguration)
self.identifierCache = try OneDriveIdentifierCache()
self.tmpDirURL = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString, isDirectory: true)
self.maxPageSize = min(max(1, maxPageSize), 1000)
try FileManager.default.createDirectory(at: tmpDirURL, withIntermediateDirectories: true)
}

public convenience init(credential: OneDriveCredential, maxPageSize: Int = .max) throws {
try self.init(credential: credential, maxPageSize: maxPageSize, urlSessionConfiguration: .default)
try self.init(credential: credential, maxPageSize: maxPageSize, urlSessionConfiguration: .default, unauthenticatedURLSessionConfiguration: .default)
}

public static func withBackgroundSession(credential: OneDriveCredential, maxPageSize: Int = .max, sessionIdentifier: String) throws -> OneDriveCloudProvider {
let configuration = URLSessionConfiguration.background(withIdentifier: sessionIdentifier)
configuration.sharedContainerIdentifier = OneDriveSetup.constants.sharedContainerIdentifier
return try OneDriveCloudProvider(credential: credential, maxPageSize: maxPageSize, urlSessionConfiguration: configuration)
let unauthenticatedConfiguration = URLSessionConfiguration.background(withIdentifier: "\(sessionIdentifier)_unauthenticated")
unauthenticatedConfiguration.sharedContainerIdentifier = OneDriveSetup.constants.sharedContainerIdentifier
return try OneDriveCloudProvider(credential: credential, maxPageSize: maxPageSize, urlSessionConfiguration: configuration, unauthenticatedURLSessionConfiguration: unauthenticatedConfiguration)
}

deinit {
Expand Down

0 comments on commit 92e6e3d

Please sign in to comment.