Browse Source

update download extension

Marino Faggiana 6 years ago
parent
commit
dca177c111

+ 1 - 1
PickerFileProvider/FileProviderExtension.swift

@@ -400,7 +400,7 @@ class FileProviderExtension: NSFileProviderExtension, CCNetworkingDelegate {
             _ = self.deleteFile("\(providerData.directoryUser)/\(metadata.fileID).ico")
 
             let ocNetworking = OCnetworking.init(delegate: nil, metadataNet: nil, withUser: providerData.accountUser, withUserID: providerData.accountUserID, withPassword: providerData.accountPassword, withUrl: providerData.accountUrl)
-            let task = ocNetworking?.downloadFileNameServerUrl("\(serverUrl)/\(metadata.fileName)", fileNameLocalPath: "\(providerData.directoryUser)/\(metadata.fileID)", communication: CCNetworking.shared().sharedOCCommunicationExtensionDownload(metadata.fileName), success: { (lenght, etag, date) in
+            let task = ocNetworking?.downloadFileNameServerUrl("\(serverUrl)/\(metadata.fileName)", fileNameLocalPath: "\(providerData.directoryUser)/\(metadata.fileID)", communication: CCNetworking.shared().sharedOCCommunicationExtensionDownload(), success: { (lenght, etag, date) in
                 
                 // remove Task
                 self.outstandingDownloadTasks.removeValue(forKey: url)

+ 1 - 1
iOSClient/Networking/CCNetworking.h

@@ -49,7 +49,7 @@
 
 // Sessions
 - (OCCommunication *)sharedOCCommunication;
-- (OCCommunication *)sharedOCCommunicationExtensionDownload:(NSString *)identifier;
+- (OCCommunication *)sharedOCCommunicationExtensionDownload;
 
 - (NSURLSession *)getSessionfromSessionDescription:(NSString *)sessionDescription;
 - (NSArray *)getUploadTasksExtensionSession;

+ 3 - 5
iOSClient/Networking/CCNetworking.m

@@ -288,14 +288,13 @@
     return sharedOCCommunication;
 }
 
-- (OCCommunication *)sharedOCCommunicationExtensionDownload:(NSString *)identifier
+- (OCCommunication *)sharedOCCommunicationExtensionDownload
 {
     static OCCommunication *sharedOCCommunicationExtensionDownload = nil;
-    static NSString *extensionDownloadIdentifier = k_download_session_extension;
     
-    if (sharedOCCommunicationExtensionDownload == nil || [extensionDownloadIdentifier isEqualToString:identifier] == false)
+    if (sharedOCCommunicationExtensionDownload == nil)
     {
-        NSURLSessionConfiguration *config = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:identifier];
+        NSURLSessionConfiguration *config = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:k_download_session_extension];
         config.sharedContainerIdentifier = [NCBrandOptions sharedInstance].capabilitiesGroups;
         config.HTTPMaximumConnectionsPerHost = 1;
         config.requestCachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
@@ -309,7 +308,6 @@
             return NSURLSessionAuthChallengePerformDefaultHandling;
         }];
         
-        extensionDownloadIdentifier = identifier;
         sharedOCCommunicationExtensionDownload = [[OCCommunication alloc] initWithUploadSessionManager:nil andDownloadSessionManager:sessionManager andNetworkSessionManager:nil];
     }