Marino Faggiana 6 年之前
父節點
當前提交
0c7d2609fa
共有 1 個文件被更改,包括 20 次插入0 次删除
  1. 20 0
      iOSClient/Activity/NCActivity.swift

+ 20 - 0
iOSClient/Activity/NCActivity.swift

@@ -387,18 +387,38 @@ class activityTableViewCell: UITableViewCell, UICollectionViewDelegate, UICollec
             let url = appDelegate.activeUrl + k_webDAV + "/" + activitySubjectRich.path
             let fileNameLocalPath = CCUtility.getDirectoryProviderStorageFileID(activitySubjectRich.id, fileNameView: activitySubjectRich.name)
             
+            NCUtility.sharedInstance.startActivityIndicator(view: self)
+            
             let _ = OCNetworking.sharedManager()?.download(withAccount: activityPreview.account, url: url, fileNameLocalPath: fileNameLocalPath, completion: { (account, message, errorCode) in
                 
                 if account == self.appDelegate.activeAccount && errorCode == 0 {
+                    
                     let serverUrl = (url as NSString).deletingLastPathComponent
                     let fileName = (url as NSString).lastPathComponent
+                    
                     OCNetworking.sharedManager()?.readFile(withAccount: activityPreview.account, serverUrl: serverUrl, fileName: fileName, completion: { (account, metadata, message, errorCode) in
+                        
+                        NCUtility.sharedInstance.stopActivityIndicator()
+
                         if account == self.appDelegate.activeAccount && errorCode == 0 {
+                            
+                            // move from id to oc:id + instanceid
+                            do {
+                                let atPath = CCUtility.getDirectoryProviderStorage()! + "/" + activitySubjectRich.id
+                                let toPath = CCUtility.getDirectoryProviderStorage()! + "/" + metadata!.fileID
+                                try FileManager.default.moveItem(atPath: atPath, toPath: toPath)
+                            } catch {
+                                print(error)
+                            }
+                            
                             if let metadata = NCManageDatabase.sharedInstance.addMetadata(metadata!) {
                                 self.appDelegate.activeMain.performSegue(withIdentifier: "segueDetail", sender: metadata)
                             }
                         }
                     })
+                    
+                } else {
+                    NCUtility.sharedInstance.stopActivityIndicator()
                 }
             })
         }