Browse Source

Read Folder Items NULL

Marino Faggiana 8 years ago
parent
commit
c47fd01e15
2 changed files with 24 additions and 7 deletions
  1. 5 6
      Picker/DocumentPickerViewController.swift
  2. 19 1
      iOSClient/Networking/OCNetworking.m

+ 5 - 6
Picker/DocumentPickerViewController.swift

@@ -121,8 +121,6 @@ class recordMetadataCell: UITableViewCell {
 
 extension DocumentPickerViewController: UITableViewDataSource {
     
-    // MARK: - View Life Cycle
-
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
         
         return recordsTableMetadata.count
@@ -133,19 +131,20 @@ extension DocumentPickerViewController: UITableViewDataSource {
         let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! recordMetadataCell
         
         let recordMetadata = recordsTableMetadata[(indexPath as NSIndexPath).row]
+        let metadata = CCCoreData.insertEntity(in: recordMetadata)!
         
-        let filePath = directoryUser!+"/"+recordMetadata.fileID!+".ico"
+        // File Image View
+        let filePath = directoryUser!+"/"+metadata.fileID!+".ico"
         
         if (FileManager.default.fileExists(atPath: filePath)) {
             
-            cell.fileImageView.image = UIImage(contentsOfFile: directoryUser!+"/"+recordMetadata.fileID!+".ico")
+            cell.fileImageView.image = UIImage(contentsOfFile: filePath)
             
         } else {
             
+            cell.fileImageView.image = UIImage(named: metadata.iconName!)
         }
         
-        //let note = notes[(indexPath as NSIndexPath).row]
-        //cell.textLabel?.text = record.fileName
         return cell
     }
 }

+ 19 - 1
iOSClient/Networking/OCNetworking.m

@@ -329,6 +329,24 @@
         
         NSMutableArray *metadatas = [[NSMutableArray alloc] init];
         
+        // Check items > 0
+        if ([items count] == 0) {
+            
+#ifndef SHARE_IN
+            [app messageNotification:@"Server error" description:@"Read Folder WebDAV : [items NULL] please fix" visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeError];
+#endif
+
+            dispatch_async(dispatch_get_main_queue(), ^{
+                
+                if ([self.delegate respondsToSelector:@selector(readFolderSuccess:permissions:rev:metadatas:)])
+                    [self.delegate readFolderSuccess:_metadataNet permissions:@"" rev:@"" metadatas:metadatas];
+            });
+
+            [self complete];
+            
+            return;
+        }
+
         // directory [0]
         OCFileDto *itemDtoDirectory = [items objectAtIndex:0];
         NSString *permissions = itemDtoDirectory.permissions;
@@ -638,7 +656,7 @@
         if ([items count] == 0) {
        
 #ifndef SHARE_IN
-            [app messageNotification:@"Server error" description:@"readFile, items NULL, please fix" visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeError];
+            [app messageNotification:@"Server error" description:@"Read File WebDAV : [items NULL] please fix" visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeError];
 #endif
         }