Marino Faggiana 7 years ago
parent
commit
efce90e73a
1 changed files with 11 additions and 2 deletions
  1. 11 2
      PickerFileProvider/FileProvider.swift

+ 11 - 2
PickerFileProvider/FileProvider.swift

@@ -259,8 +259,10 @@ class FileProvider: NSFileProviderExtension {
         
         if #available(iOSApplicationExtension 11.0, *) {
 
+            let fileName = url.lastPathComponent
             let pathComponents = url.pathComponents
             let identifier = NSFileProviderItemIdentifier(pathComponents[pathComponents.count - 2])
+            let changeDocumentPath = changeDocumentURL!.path + "/" + fileName
             var fileSize : UInt64 = 0
             
             guard let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "account = %@ AND fileID = %@", account, identifier.rawValue)) else {
@@ -313,8 +315,15 @@ class FileProvider: NSFileProviderExtension {
                 
             } else {
                 
-                // Refresh
-                self.refreshEnumerator(identifier: identifier, serverUrl: serverUrl)
+                let queue = NCManageDatabase.sharedInstance.getQueueUpload(predicate: NSPredicate(format: "account = %@ AND path = %@", account, changeDocumentPath))
+                if queue?.count == 0 {
+                    // Upload
+                    self.uploadCloud(fileName, serverUrl: serverUrl, fileNameLocalPath: changeDocumentPath, metadata: metadata, identifier: identifier)
+                } else {
+                    // Refresh
+                    self.refreshEnumerator(identifier: identifier, serverUrl: serverUrl)
+                }
+                
                 // Exists
                 completionHandler(nil)
             }