Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Sources/NextcloudKit/NKCommon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ public struct NKCommon: Sendable {
public var delegate: NextcloudKitDelegate?
public var groupIdentifier: String?

// Foreground
public let identifierSessionDownload: String = "com.nextcloud.nextcloudkit.session.download"
public let identifierSessionUpload: String = "com.nextcloud.nextcloudkit.session.upload"
// Background
public let identifierSessionDownloadBackground: String = "com.nextcloud.session.downloadbackground"
public let identifierSessionUploadBackground: String = "com.nextcloud.session.uploadbackground"
public let identifierSessionUploadBackgroundWWan: String = "com.nextcloud.session.uploadbackgroundWWan"
Expand Down Expand Up @@ -474,6 +476,10 @@ public struct NKCommon: Sendable {

// MARK: - Common

public func getSessionConfigurationIdentifier(_ identifier: String, account: String) -> String {
return "\(identifier).\(account)"
}

public func getSession(account: String) -> NKSession? {
var session: NKSession?
nksessions.forEach { result in
Expand Down
6 changes: 3 additions & 3 deletions Sources/NextcloudKit/NKSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public struct NKSession: Sendable {
eventMonitors: [NKMonitor(nkCommonInstance: nkCommonInstance)])

/// Session Download Background
let configurationDownloadBackground = URLSessionConfiguration.background(withIdentifier: NKCommon().identifierSessionDownloadBackground)
let configurationDownloadBackground = URLSessionConfiguration.background(withIdentifier: NKCommon().getSessionConfigurationIdentifier(NKCommon().identifierSessionDownloadBackground, account: account))
configurationDownloadBackground.allowsCellularAccess = true

if #available(macOS 11, *) {
Expand All @@ -93,7 +93,7 @@ public struct NKSession: Sendable {
sessionDownloadBackground = URLSession(configuration: configurationDownloadBackground, delegate: backgroundSessionDelegate, delegateQueue: OperationQueue.main)

/// Session Upload Background
let configurationUploadBackground = URLSessionConfiguration.background(withIdentifier: NKCommon().identifierSessionUploadBackground)
let configurationUploadBackground = URLSessionConfiguration.background(withIdentifier: NKCommon().getSessionConfigurationIdentifier(NKCommon().identifierSessionUploadBackground, account: account))
configurationUploadBackground.allowsCellularAccess = true

if #available(macOS 11, *) {
Expand All @@ -112,7 +112,7 @@ public struct NKSession: Sendable {
sessionUploadBackground = URLSession(configuration: configurationUploadBackground, delegate: backgroundSessionDelegate, delegateQueue: OperationQueue.main)

/// Session Upload Background WWan
let configurationUploadBackgroundWWan = URLSessionConfiguration.background(withIdentifier: NKCommon().identifierSessionUploadBackgroundWWan)
let configurationUploadBackgroundWWan = URLSessionConfiguration.background(withIdentifier: NKCommon().getSessionConfigurationIdentifier(NKCommon().identifierSessionUploadBackgroundWWan, account: account))
configurationUploadBackgroundWWan.allowsCellularAccess = false

if #available(macOS 11, *) {
Expand Down
Loading