|
@@ -38,8 +38,9 @@ import Photos
|
|
@objc protocol uploadE2EEDelegate: AnyObject { }
|
|
@objc protocol uploadE2EEDelegate: AnyObject { }
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-@objc class NCNetworking: NSObject, NKCommonDelegate {
|
|
|
|
- @objc public static let shared: NCNetworking = {
|
|
|
|
|
|
+@objcMembers
|
|
|
|
+class NCNetworking: NSObject, NKCommonDelegate {
|
|
|
|
+ public static let shared: NCNetworking = {
|
|
let instance = NCNetworking()
|
|
let instance = NCNetworking()
|
|
return instance
|
|
return instance
|
|
}()
|
|
}()
|
|
@@ -51,36 +52,41 @@ import Photos
|
|
let downloadRequest = ThreadSafeDictionary<String,DownloadRequest>()
|
|
let downloadRequest = ThreadSafeDictionary<String,DownloadRequest>()
|
|
let uploadRequest = ThreadSafeDictionary<String,UploadRequest>()
|
|
let uploadRequest = ThreadSafeDictionary<String,UploadRequest>()
|
|
let uploadMetadataInBackground = ThreadSafeDictionary<String,tableMetadata>()
|
|
let uploadMetadataInBackground = ThreadSafeDictionary<String,tableMetadata>()
|
|
|
|
+
|
|
|
|
+ lazy var nkBackground: NKBackground = {
|
|
|
|
+ let nckb = NKBackground(nkCommonInstance: NextcloudKit.shared.nkCommonInstance)
|
|
|
|
+ return nckb
|
|
|
|
+ }()
|
|
|
|
|
|
- @objc public let sessionMaximumConnectionsPerHost = 5
|
|
|
|
- @objc public let sessionIdentifierBackground: String = "com.nextcloud.session.upload.background"
|
|
|
|
- @objc public let sessionIdentifierBackgroundWWan: String = "com.nextcloud.session.upload.backgroundWWan"
|
|
|
|
- @objc public let sessionIdentifierBackgroundExtension: String = "com.nextcloud.session.upload.extension"
|
|
|
|
|
|
+ public let sessionMaximumConnectionsPerHost = 5
|
|
|
|
+ public let sessionIdentifierBackground: String = "com.nextcloud.session.upload.background"
|
|
|
|
+ public let sessionIdentifierBackgroundWWan: String = "com.nextcloud.session.upload.backgroundWWan"
|
|
|
|
+ public let sessionIdentifierBackgroundExtension: String = "com.nextcloud.session.upload.extension"
|
|
|
|
|
|
- @objc public lazy var sessionManagerBackground: URLSession = {
|
|
|
|
|
|
+ public lazy var sessionManagerBackground: URLSession = {
|
|
let configuration = URLSessionConfiguration.background(withIdentifier: sessionIdentifierBackground)
|
|
let configuration = URLSessionConfiguration.background(withIdentifier: sessionIdentifierBackground)
|
|
configuration.allowsCellularAccess = true
|
|
configuration.allowsCellularAccess = true
|
|
configuration.sessionSendsLaunchEvents = true
|
|
configuration.sessionSendsLaunchEvents = true
|
|
configuration.isDiscretionary = false
|
|
configuration.isDiscretionary = false
|
|
configuration.httpMaximumConnectionsPerHost = sessionMaximumConnectionsPerHost
|
|
configuration.httpMaximumConnectionsPerHost = sessionMaximumConnectionsPerHost
|
|
configuration.requestCachePolicy = NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData
|
|
configuration.requestCachePolicy = NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData
|
|
- let session = URLSession(configuration: configuration, delegate: NKBackground.shared, delegateQueue: OperationQueue.main)
|
|
|
|
|
|
+ let session = URLSession(configuration: configuration, delegate: nkBackground, delegateQueue: OperationQueue.main)
|
|
return session
|
|
return session
|
|
}()
|
|
}()
|
|
|
|
|
|
- @objc public lazy var sessionManagerBackgroundWWan: URLSession = {
|
|
|
|
|
|
+ public lazy var sessionManagerBackgroundWWan: URLSession = {
|
|
let configuration = URLSessionConfiguration.background(withIdentifier: sessionIdentifierBackgroundWWan)
|
|
let configuration = URLSessionConfiguration.background(withIdentifier: sessionIdentifierBackgroundWWan)
|
|
configuration.allowsCellularAccess = false
|
|
configuration.allowsCellularAccess = false
|
|
configuration.sessionSendsLaunchEvents = true
|
|
configuration.sessionSendsLaunchEvents = true
|
|
configuration.isDiscretionary = false
|
|
configuration.isDiscretionary = false
|
|
configuration.httpMaximumConnectionsPerHost = sessionMaximumConnectionsPerHost
|
|
configuration.httpMaximumConnectionsPerHost = sessionMaximumConnectionsPerHost
|
|
configuration.requestCachePolicy = NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData
|
|
configuration.requestCachePolicy = NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData
|
|
- let session = URLSession(configuration: configuration, delegate: NKBackground.shared, delegateQueue: OperationQueue.main)
|
|
|
|
|
|
+ let session = URLSession(configuration: configuration, delegate: nkBackground, delegateQueue: OperationQueue.main)
|
|
return session
|
|
return session
|
|
}()
|
|
}()
|
|
|
|
|
|
#if EXTENSION
|
|
#if EXTENSION
|
|
- @objc public lazy var sessionManagerBackgroundExtension: URLSession = {
|
|
|
|
|
|
+ public lazy var sessionManagerBackgroundExtension: URLSession = {
|
|
let configuration = URLSessionConfiguration.background(withIdentifier: sessionIdentifierBackgroundExtension)
|
|
let configuration = URLSessionConfiguration.background(withIdentifier: sessionIdentifierBackgroundExtension)
|
|
configuration.allowsCellularAccess = true
|
|
configuration.allowsCellularAccess = true
|
|
configuration.sessionSendsLaunchEvents = true
|
|
configuration.sessionSendsLaunchEvents = true
|
|
@@ -88,26 +94,24 @@ import Photos
|
|
configuration.httpMaximumConnectionsPerHost = sessionMaximumConnectionsPerHost
|
|
configuration.httpMaximumConnectionsPerHost = sessionMaximumConnectionsPerHost
|
|
configuration.requestCachePolicy = NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData
|
|
configuration.requestCachePolicy = NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData
|
|
configuration.sharedContainerIdentifier = NCBrandOptions.shared.capabilitiesGroups
|
|
configuration.sharedContainerIdentifier = NCBrandOptions.shared.capabilitiesGroups
|
|
- let session = URLSession(configuration: configuration, delegate: NKBackground.shared, delegateQueue: OperationQueue.main)
|
|
|
|
|
|
+ let session = URLSession(configuration: configuration, delegate: nkBackground, delegateQueue: OperationQueue.main)
|
|
return session
|
|
return session
|
|
}()
|
|
}()
|
|
#endif
|
|
#endif
|
|
|
|
|
|
// REQUESTS
|
|
// REQUESTS
|
|
-
|
|
|
|
var requestsUnifiedSearch: [DataRequest] = []
|
|
var requestsUnifiedSearch: [DataRequest] = []
|
|
|
|
|
|
-
|
|
|
|
// MARK: - init
|
|
// MARK: - init
|
|
|
|
|
|
override init() {
|
|
override init() {
|
|
super.init()
|
|
super.init()
|
|
|
|
|
|
#if EXTENSION
|
|
#if EXTENSION
|
|
- _ = sessionIdentifierBackgroundExtension
|
|
|
|
|
|
+ print("Start Background Extension: ", sessionIdentifierBackgroundExtension)
|
|
#else
|
|
#else
|
|
- _ = sessionManagerBackground
|
|
|
|
- _ = sessionManagerBackgroundWWan
|
|
|
|
|
|
+ print("Start Background: ", sessionManagerBackground)
|
|
|
|
+ print("Start BackgroundWWan: ", sessionManagerBackgroundWWan)
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|
|
@@ -150,7 +154,7 @@ import Photos
|
|
|
|
|
|
#if !EXTENSION
|
|
#if !EXTENSION
|
|
if let appDelegate = UIApplication.shared.delegate as? AppDelegate, let completionHandler = appDelegate.backgroundSessionCompletionHandler {
|
|
if let appDelegate = UIApplication.shared.delegate as? AppDelegate, let completionHandler = appDelegate.backgroundSessionCompletionHandler {
|
|
- NKCommon.shared.writeLog("[INFO] Called urlSessionDidFinishEvents for Background URLSession")
|
|
|
|
|
|
+ NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Called urlSessionDidFinishEvents for Background URLSession")
|
|
appDelegate.backgroundSessionCompletionHandler = nil
|
|
appDelegate.backgroundSessionCompletionHandler = nil
|
|
completionHandler()
|
|
completionHandler()
|
|
}
|
|
}
|
|
@@ -208,7 +212,7 @@ import Photos
|
|
let certificateToPath = directoryCertificate + "/" + host + ".der"
|
|
let certificateToPath = directoryCertificate + "/" + host + ".der"
|
|
|
|
|
|
if !NCUtilityFileSystem.shared.copyFile(atPath: certificateAtPath, toPath: certificateToPath) {
|
|
if !NCUtilityFileSystem.shared.copyFile(atPath: certificateAtPath, toPath: certificateToPath) {
|
|
- NKCommon.shared.writeLog("[ERROR] Write certificare error")
|
|
|
|
|
|
+ NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] Write certificare error")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -220,7 +224,7 @@ import Photos
|
|
let x509cert = d2i_X509_bio(mem, nil)
|
|
let x509cert = d2i_X509_bio(mem, nil)
|
|
|
|
|
|
if x509cert == nil {
|
|
if x509cert == nil {
|
|
- NKCommon.shared.writeLog("[ERROR] OpenSSL couldn't parse X509 Certificate")
|
|
|
|
|
|
+ NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] OpenSSL couldn't parse X509 Certificate")
|
|
} else {
|
|
} else {
|
|
// save details
|
|
// save details
|
|
if FileManager.default.fileExists(atPath: certNamePathTXT) {
|
|
if FileManager.default.fileExists(atPath: certNamePathTXT) {
|
|
@@ -312,7 +316,7 @@ import Photos
|
|
|
|
|
|
// MARK: - Download
|
|
// MARK: - Download
|
|
|
|
|
|
- @objc func cancelDownload(ocId: String, serverUrl: String, fileNameView: String) {
|
|
|
|
|
|
+ func cancelDownload(ocId: String, serverUrl: String, fileNameView: String) {
|
|
|
|
|
|
guard let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView) else { return }
|
|
guard let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView) else { return }
|
|
|
|
|
|
@@ -338,9 +342,9 @@ import Photos
|
|
|
|
|
|
if metadata.isDownloadUpload { return }
|
|
if metadata.isDownloadUpload { return }
|
|
|
|
|
|
- NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: NKCommon.shared.sessionIdentifierDownload, sessionError: "", sessionSelector: selector, sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusInDownload)
|
|
|
|
|
|
+ NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: NextcloudKit.shared.nkCommonInstance.sessionIdentifierDownload, sessionError: "", sessionSelector: selector, sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusInDownload)
|
|
|
|
|
|
- NextcloudKit.shared.download(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, queue: NKCommon.shared.backgroundQueue, requestHandler: { request in
|
|
|
|
|
|
+ NextcloudKit.shared.download(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue, requestHandler: { request in
|
|
|
|
|
|
requestHandler(request)
|
|
requestHandler(request)
|
|
|
|
|
|
@@ -398,7 +402,7 @@ import Photos
|
|
completion: @escaping (_ error: NKError) -> () = { error in }) {
|
|
completion: @escaping (_ error: NKError) -> () = { error in }) {
|
|
|
|
|
|
let metadata = tableMetadata.init(value: metadata)
|
|
let metadata = tableMetadata.init(value: metadata)
|
|
- NKCommon.shared.writeLog("[INFO] Upload file \(metadata.fileNameView) with Identifier \(metadata.assetLocalIdentifier) with size \(metadata.size) [CHUNCK \(metadata.chunk), E2EE \(metadata.isDirectoryE2EE)]")
|
|
|
|
|
|
+ NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Upload file \(metadata.fileNameView) with Identifier \(metadata.assetLocalIdentifier) with size \(metadata.size) [CHUNCK \(metadata.chunk), E2EE \(metadata.isDirectoryE2EE)]")
|
|
|
|
|
|
if metadata.isDirectoryE2EE {
|
|
if metadata.isDirectoryE2EE {
|
|
#if !EXTENSION_FILE_PROVIDER_EXTENSION && !EXTENSION_WIDGET
|
|
#if !EXTENSION_FILE_PROVIDER_EXTENSION && !EXTENSION_WIDGET
|
|
@@ -411,7 +415,7 @@ import Photos
|
|
uploadChunkedFile(metadata: metadata, start: start, progressHandler: progressHandler) { error in
|
|
uploadChunkedFile(metadata: metadata, start: start, progressHandler: progressHandler) { error in
|
|
completion(error)
|
|
completion(error)
|
|
}
|
|
}
|
|
- } else if metadata.session == NKCommon.shared.sessionIdentifierUpload {
|
|
|
|
|
|
+ } else if metadata.session == NextcloudKit.shared.nkCommonInstance.sessionIdentifierUpload {
|
|
let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
|
|
let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
|
|
uploadFile(metadata: metadata, fileNameLocalPath:fileNameLocalPath, start: start, progressHandler: progressHandler) { account, ocId, etag, date, size, allHeaderFields, afError, error in
|
|
uploadFile(metadata: metadata, fileNameLocalPath:fileNameLocalPath, start: start, progressHandler: progressHandler) { account, ocId, etag, date, size, allHeaderFields, afError, error in
|
|
completion(error)
|
|
completion(error)
|
|
@@ -494,9 +498,9 @@ import Photos
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
- if let task = NKBackground.shared.upload(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, dateCreationFile: metadata.creationDate as Date, dateModificationFile: metadata.date as Date, description: metadata.ocId, session: session!) {
|
|
|
|
|
|
+ if let task = nkBackground.upload(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, dateCreationFile: metadata.creationDate as Date, dateModificationFile: metadata.date as Date, description: metadata.ocId, session: session!) {
|
|
|
|
|
|
- NKCommon.shared.writeLog("[INFO] Upload file \(metadata.fileNameView) with task with taskIdentifier \(task.taskIdentifier)")
|
|
|
|
|
|
+ NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Upload file \(metadata.fileNameView) with task with taskIdentifier \(task.taskIdentifier)")
|
|
|
|
|
|
NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, sessionError: "", sessionTaskIdentifier: task.taskIdentifier, status: NCGlobal.shared.metadataStatusUploading)
|
|
NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, sessionError: "", sessionTaskIdentifier: task.taskIdentifier, status: NCGlobal.shared.metadataStatusUploading)
|
|
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadStartFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account, "fileName": metadata.fileName, "sessionSelector": metadata.sessionSelector])
|
|
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadStartFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account, "fileName": metadata.fileName, "sessionSelector": metadata.sessionSelector])
|
|
@@ -555,7 +559,7 @@ import Photos
|
|
NCUtilityFileSystem.shared.deleteFile(filePath: CCUtility.getDirectoryProviderStorageOcId(ocIdTemp))
|
|
NCUtilityFileSystem.shared.deleteFile(filePath: CCUtility.getDirectoryProviderStorageOcId(ocIdTemp))
|
|
}
|
|
}
|
|
|
|
|
|
- NKCommon.shared.writeLog("[SUCCESS] Upload complete " + serverUrl + "/" + fileName + ", result: success(\(size) bytes)")
|
|
|
|
|
|
+ NextcloudKit.shared.nkCommonInstance.writeLog("[SUCCESS] Upload complete " + serverUrl + "/" + fileName + ", result: success(\(size) bytes)")
|
|
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadedFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account, "fileName": metadata.fileName, "ocIdTemp": ocIdTemp, "error": error])
|
|
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadedFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account, "fileName": metadata.fileName, "ocIdTemp": ocIdTemp, "error": error])
|
|
|
|
|
|
} else {
|
|
} else {
|
|
@@ -662,13 +666,13 @@ import Photos
|
|
return completion()
|
|
return completion()
|
|
}
|
|
}
|
|
|
|
|
|
- if metadata.session == NKCommon.shared.sessionIdentifierDownload {
|
|
|
|
|
|
+ if metadata.session == NextcloudKit.shared.nkCommonInstance.sessionIdentifierDownload {
|
|
|
|
|
|
NCNetworking.shared.cancelDownload(ocId: metadata.ocId, serverUrl: metadata.serverUrl, fileNameView: metadata.fileNameView)
|
|
NCNetworking.shared.cancelDownload(ocId: metadata.ocId, serverUrl: metadata.serverUrl, fileNameView: metadata.fileNameView)
|
|
return completion()
|
|
return completion()
|
|
}
|
|
}
|
|
|
|
|
|
- if metadata.session == NKCommon.shared.sessionIdentifierUpload || metadata.chunk {
|
|
|
|
|
|
+ if metadata.session == NextcloudKit.shared.nkCommonInstance.sessionIdentifierUpload || metadata.chunk {
|
|
|
|
|
|
guard let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) else { return }
|
|
guard let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) else { return }
|
|
|
|
|
|
@@ -752,7 +756,7 @@ import Photos
|
|
if metadata.status == NCGlobal.shared.metadataStatusWaitDownload || metadata.status == NCGlobal.shared.metadataStatusDownloadError {
|
|
if metadata.status == NCGlobal.shared.metadataStatusWaitDownload || metadata.status == NCGlobal.shared.metadataStatusDownloadError {
|
|
NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: "", sessionError: "", sessionSelector: "", sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusNormal)
|
|
NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: "", sessionError: "", sessionSelector: "", sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusNormal)
|
|
}
|
|
}
|
|
- if metadata.status == NCGlobal.shared.metadataStatusDownloading && metadata.session == NKCommon.shared.sessionIdentifierDownload {
|
|
|
|
|
|
+ if metadata.status == NCGlobal.shared.metadataStatusDownloading && metadata.session == NextcloudKit.shared.nkCommonInstance.sessionIdentifierDownload {
|
|
cancelDownload(ocId: metadata.ocId, serverUrl: metadata.serverUrl, fileNameView: metadata.fileNameView)
|
|
cancelDownload(ocId: metadata.ocId, serverUrl: metadata.serverUrl, fileNameView: metadata.fileNameView)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -766,7 +770,7 @@ import Photos
|
|
|
|
|
|
@objc func readFolder(serverUrl: String, account: String, completion: @escaping (_ account: String, _ metadataFolder: tableMetadata?, _ metadatas: [tableMetadata]?, _ metadatasUpdate: [tableMetadata]?, _ metadatasLocalUpdate: [tableMetadata]?, _ metadatasDelete: [tableMetadata]?, _ error: NKError) -> Void) {
|
|
@objc func readFolder(serverUrl: String, account: String, completion: @escaping (_ account: String, _ metadataFolder: tableMetadata?, _ metadatas: [tableMetadata]?, _ metadatasUpdate: [tableMetadata]?, _ metadatasLocalUpdate: [tableMetadata]?, _ metadatasDelete: [tableMetadata]?, _ error: NKError) -> Void) {
|
|
|
|
|
|
- let options = NKRequestOptions(queue: NKCommon.shared.backgroundQueue)
|
|
|
|
|
|
+ let options = NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
|
|
|
|
|
|
NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", showHiddenFiles: CCUtility.getShowHiddenFiles(), includeHiddenFiles: NCGlobal.shared.includeHiddenFiles ,options: options) { account, files, _, error in
|
|
NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", showHiddenFiles: CCUtility.getShowHiddenFiles(), includeHiddenFiles: NCGlobal.shared.includeHiddenFiles ,options: options) { account, files, _, error in
|
|
guard error == .success else {
|
|
guard error == .success else {
|
|
@@ -797,7 +801,7 @@ import Photos
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @objc func readFile(serverUrlFileName: String, showHiddenFiles: Bool = CCUtility.getShowHiddenFiles(), queue: DispatchQueue = NKCommon.shared.backgroundQueue, completion: @escaping (_ account: String, _ metadata: tableMetadata?, _ error: NKError) -> Void) {
|
|
|
|
|
|
+ func readFile(serverUrlFileName: String, showHiddenFiles: Bool = CCUtility.getShowHiddenFiles(), queue: DispatchQueue = NextcloudKit.shared.nkCommonInstance.backgroundQueue, completion: @escaping (_ account: String, _ metadata: tableMetadata?, _ error: NKError) -> Void) {
|
|
|
|
|
|
let options = NKRequestOptions(queue: queue)
|
|
let options = NKRequestOptions(queue: queue)
|
|
|
|
|
|
@@ -839,7 +843,7 @@ import Photos
|
|
<d:prop></d:prop>
|
|
<d:prop></d:prop>
|
|
</d:propfind>
|
|
</d:propfind>
|
|
"""
|
|
"""
|
|
- let options = NKRequestOptions(queue: NKCommon.shared.backgroundQueue)
|
|
|
|
|
|
+ let options = NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
|
|
|
|
|
|
NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, depth: "0", requestBody: requestBody.data(using: .utf8), options: options) { account, files, _, error in
|
|
NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, depth: "0", requestBody: requestBody.data(using: .utf8), options: options) { account, files, _, error in
|
|
if error == .success, let file = files.first {
|
|
if error == .success, let file = files.first {
|
|
@@ -855,9 +859,9 @@ import Photos
|
|
//MARK: - Search
|
|
//MARK: - Search
|
|
|
|
|
|
/// WebDAV search
|
|
/// WebDAV search
|
|
- @objc func searchFiles(urlBase: NCUserBaseUrl, literal: String, completion: @escaping (_ metadatas: [tableMetadata]?, _ error: NKError) -> ()) {
|
|
|
|
|
|
+ func searchFiles(urlBase: NCUserBaseUrl, literal: String, completion: @escaping (_ metadatas: [tableMetadata]?, _ error: NKError) -> ()) {
|
|
|
|
|
|
- let options = NKRequestOptions(queue: NKCommon.shared.backgroundQueue)
|
|
|
|
|
|
+ let options = NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
|
|
|
|
|
|
NextcloudKit.shared.searchLiteral(serverUrl: urlBase.urlBase, depth: "infinity", literal: literal, showHiddenFiles: CCUtility.getShowHiddenFiles(), options: options) { (account, files, data, error) in
|
|
NextcloudKit.shared.searchLiteral(serverUrl: urlBase.urlBase, depth: "infinity", literal: literal, showHiddenFiles: CCUtility.getShowHiddenFiles(), options: options) { (account, files, data, error) in
|
|
guard error == .success else {
|
|
guard error == .success else {
|
|
@@ -1030,7 +1034,7 @@ import Photos
|
|
|
|
|
|
// MARK: - WebDav Create Folder
|
|
// MARK: - WebDav Create Folder
|
|
|
|
|
|
- @objc func createFolder(fileName: String, serverUrl: String, account: String, urlBase: String, userId: String, overwrite: Bool = false, withPush:Bool, completion: @escaping (_ error: NKError) -> Void) {
|
|
|
|
|
|
+ func createFolder(fileName: String, serverUrl: String, account: String, urlBase: String, userId: String, overwrite: Bool = false, withPush:Bool, completion: @escaping (_ error: NKError) -> Void) {
|
|
|
|
|
|
let isDirectoryEncrypted = NCUtility.shared.isDirectoryE2EE(serverUrl: serverUrl, account: account, urlBase: urlBase, userId: userId)
|
|
let isDirectoryEncrypted = NCUtility.shared.isDirectoryE2EE(serverUrl: serverUrl, account: account, urlBase: urlBase, userId: userId)
|
|
let fileName = fileName.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
let fileName = fileName.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
@@ -1141,7 +1145,7 @@ import Photos
|
|
|
|
|
|
// MARK: - WebDav Delete
|
|
// MARK: - WebDav Delete
|
|
|
|
|
|
- @objc func deleteMetadata(_ metadata: tableMetadata, onlyLocalCache: Bool, completion: @escaping (_ error: NKError) -> Void) {
|
|
|
|
|
|
+ func deleteMetadata(_ metadata: tableMetadata, onlyLocalCache: Bool, completion: @escaping (_ error: NKError) -> Void) {
|
|
|
|
|
|
if onlyLocalCache {
|
|
if onlyLocalCache {
|
|
|
|
|
|
@@ -1247,7 +1251,7 @@ import Photos
|
|
|
|
|
|
// MARK: - WebDav Favorite
|
|
// MARK: - WebDav Favorite
|
|
|
|
|
|
- @objc func favoriteMetadata(_ metadata: tableMetadata, completion: @escaping (_ error: NKError) -> Void) {
|
|
|
|
|
|
+ func favoriteMetadata(_ metadata: tableMetadata, completion: @escaping (_ error: NKError) -> Void) {
|
|
|
|
|
|
if let metadataLive = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata) {
|
|
if let metadataLive = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata) {
|
|
favoriteMetadataPlain(metadataLive) { error in
|
|
favoriteMetadataPlain(metadataLive) { error in
|
|
@@ -1282,9 +1286,9 @@ import Photos
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @objc func listingFavoritescompletion(selector: String, completion: @escaping (_ account: String, _ metadatas: [tableMetadata]?, _ error: NKError) -> Void) {
|
|
|
|
|
|
+ func listingFavoritescompletion(selector: String, completion: @escaping (_ account: String, _ metadatas: [tableMetadata]?, _ error: NKError) -> Void) {
|
|
|
|
|
|
- let options = NKRequestOptions(queue: NKCommon.shared.backgroundQueue)
|
|
|
|
|
|
+ let options = NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
|
|
|
|
|
|
NextcloudKit.shared.listingFavorites(showHiddenFiles: CCUtility.getShowHiddenFiles(), options: options) { account, files, data, error in
|
|
NextcloudKit.shared.listingFavorites(showHiddenFiles: CCUtility.getShowHiddenFiles(), options: options) { account, files, data, error in
|
|
guard error == .success else {
|
|
guard error == .success else {
|
|
@@ -1308,7 +1312,7 @@ import Photos
|
|
|
|
|
|
// MARK: - Lock Files
|
|
// MARK: - Lock Files
|
|
|
|
|
|
- @objc func lockUnlockFile(_ metadata: tableMetadata, shoulLock: Bool) {
|
|
|
|
|
|
+ func lockUnlockFile(_ metadata: tableMetadata, shoulLock: Bool) {
|
|
NextcloudKit.shared.lockUnlockFile(serverUrlFileName: metadata.serverUrl + "/" + metadata.fileName, shouldLock: shoulLock) { account, error in
|
|
NextcloudKit.shared.lockUnlockFile(serverUrlFileName: metadata.serverUrl + "/" + metadata.fileName, shouldLock: shoulLock) { account, error in
|
|
// 0: lock was successful; 412: lock did not change, no error, refresh
|
|
// 0: lock was successful; 412: lock did not change, no error, refresh
|
|
guard error == .success || error.errorCode == NCGlobal.shared.errorPreconditionFailed else {
|
|
guard error == .success || error.errorCode == NCGlobal.shared.errorPreconditionFailed else {
|
|
@@ -1326,7 +1330,7 @@ import Photos
|
|
|
|
|
|
// MARK: - WebDav Rename
|
|
// MARK: - WebDav Rename
|
|
|
|
|
|
- @objc func renameMetadata(_ metadata: tableMetadata, fileNameNew: String, viewController: UIViewController?, completion: @escaping (_ error: NKError) -> Void) {
|
|
|
|
|
|
+ func renameMetadata(_ metadata: tableMetadata, fileNameNew: String, viewController: UIViewController?, completion: @escaping (_ error: NKError) -> Void) {
|
|
|
|
|
|
let metadataLive = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata)
|
|
let metadataLive = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata)
|
|
let fileNameNew = fileNameNew.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
let fileNameNew = fileNameNew.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
@@ -1473,7 +1477,7 @@ import Photos
|
|
|
|
|
|
// MARK: - WebDav Copy
|
|
// MARK: - WebDav Copy
|
|
|
|
|
|
- @objc func copyMetadata(_ metadata: tableMetadata, serverUrlTo: String, overwrite: Bool, completion: @escaping (_ error: NKError) -> Void) {
|
|
|
|
|
|
+ func copyMetadata(_ metadata: tableMetadata, serverUrlTo: String, overwrite: Bool, completion: @escaping (_ error: NKError) -> Void) {
|
|
|
|
|
|
if let metadataLive = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata) {
|
|
if let metadataLive = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata) {
|
|
copyMetadataPlain(metadataLive, serverUrlTo: serverUrlTo, overwrite: overwrite) { error in
|
|
copyMetadataPlain(metadataLive, serverUrlTo: serverUrlTo, overwrite: overwrite) { error in
|