Browse Source

fix activity view

Marino Faggiana 6 years ago
parent
commit
def3fbcd7a
1 changed files with 17 additions and 10 deletions
  1. 17 10
      iOSClient/Activity/NCActivity.swift

+ 17 - 10
iOSClient/Activity/NCActivity.swift

@@ -412,9 +412,18 @@ class activityTableViewCell: UITableViewCell, UICollectionViewDelegate, UICollec
             }
             
             if let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "fileID CONTAINS %@", activitySubjectRich.id)) {
-                
-                self.appDelegate.activeMain.performSegue(withIdentifier: "segueDetail", sender: metadata)
-                return
+                if let filePath = CCUtility.getDirectoryProviderStorageFileID(metadata.fileID, fileNameView: metadata.fileNameView) {
+                    do {
+                        let attr = try FileManager.default.attributesOfItem(atPath: filePath)
+                        let fileSize = attr[FileAttributeKey.size] as! UInt64
+                        if fileSize > 0 {
+                            self.appDelegate.activeMain.performSegue(withIdentifier: "segueDetail", sender: metadata)
+                            return
+                        }
+                    } catch {
+                        print("Error: \(error)")
+                    }
+                }
             }
             
             var pathComponents = activityPreview.link.components(separatedBy: "?")
@@ -440,13 +449,11 @@ class activityTableViewCell: UITableViewCell, UICollectionViewDelegate, UICollec
                         if account == self.appDelegate.activeAccount && errorCode == 0 {
                             
                             // move from id to oc:id + instanceid (fileID)
-                            do {
-                                let atPath = CCUtility.getDirectoryProviderStorage()! + "/" + activitySubjectRich.id
-                                let toPath = CCUtility.getDirectoryProviderStorage()! + "/" + metadata!.fileID
-                                try FileManager.default.moveItem(atPath: atPath, toPath: toPath)
-                            } catch {
-                                print(error)
-                            }
+                            
+                            let atPath = CCUtility.getDirectoryProviderStorage()! + "/" + activitySubjectRich.id
+                            let toPath = CCUtility.getDirectoryProviderStorage()! + "/" + metadata!.fileID
+                            
+                            CCUtility.moveFile(atPath: atPath, toPath: toPath)
                             
                             if let metadata = NCManageDatabase.sharedInstance.addMetadata(metadata!) {
                                 self.appDelegate.activeMain.performSegue(withIdentifier: "segueDetail", sender: metadata)