浏览代码

search API

Marino Faggiana 8 年之前
父节点
当前提交
2e0fb90c4e

+ 1 - 1
Libraries external/OCCommunicationLib/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.m

@@ -294,7 +294,7 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     
     
     
     
     // OCFileDto
     // OCFileDto
-    body = [body stringByAppendingString:@"<d:resourcetype/><oc:fileid/><d:getcontenttype/><d:getetag/><d:creationdate/><oc:size/><d:getcontentlength/><d:getlastmodified/><oc:id/><oc:permissions/><oc:favorite/><d:quota-available-bytes/><d:quota-used-bytes/>"];
+    body = [body stringByAppendingString:@"<d:resourcetype/><oc:fileid/><d:getcontenttype/><d:getetag/><d:creationdate/><oc:size/><d:getcontentlength/><d:getlastmodified/><oc:id/><oc:permissions/><d:quota-available-bytes/><d:quota-used-bytes/><oc:favorite/>"];
     
     
     
     
     body = [NSString stringWithFormat:@"%@</d:prop></d:select><d:from><d:scope><d:href>/files/%@</d:href><d:depth>infinity</d:depth></d:scope></d:from><d:where><d:like><d:prop><d:displayname/></d:prop><d:literal>%%%@%%</d:literal></d:like></d:where><d:orderby/></d:basicsearch></d:searchrequest>", body, user, fileName];
     body = [NSString stringWithFormat:@"%@</d:prop></d:select><d:from><d:scope><d:href>/files/%@</d:href><d:depth>infinity</d:depth></d:scope></d:from><d:where><d:like><d:prop><d:displayname/></d:prop><d:literal>%%%@%%</d:literal></d:like></d:where><d:orderby/></d:basicsearch></d:searchrequest>", body, user, fileName];

+ 36 - 1
iOSClient/Networking/OCNetworking.m

@@ -301,7 +301,7 @@
     
     
     [communication readFolder:_metadataNet.serverUrl withUserSessionToken:nil onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token) {
     [communication readFolder:_metadataNet.serverUrl withUserSessionToken:nil onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token) {
         
         
-        NSMutableArray *metadatas = [[NSMutableArray alloc] init];
+        NSMutableArray *metadatas = [NSMutableArray new];
         
         
         // Check items > 0
         // Check items > 0
         if ([items count] == 0) {
         if ([items count] == 0) {
@@ -430,6 +430,41 @@
     
     
     [communication search:path fileName:_metadataNet.fileName depth:_metadataNet.options withUserSessionToken:nil onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token) {
     [communication search:path fileName:_metadataNet.fileName depth:_metadataNet.options withUserSessionToken:nil onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token) {
         
         
+        NSMutableArray *metadatas = [NSMutableArray new];
+        
+        NSString *cameraFolderName = [CCCoreData getCameraUploadFolderNameActiveAccount:_metadataNet.account];
+        NSString *cameraFolderPath = [CCCoreData getCameraUploadFolderPathActiveAccount:_metadataNet.account activeUrl:_activeUrl];
+        NSString *directoryUser = [CCUtility getDirectoryActiveUser:_activeUser activeUrl:_activeUrl];
+
+        for(OCFileDto *itemDto in items) {
+            
+            itemDto.fileName = [itemDto.fileName stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+            
+            // Not in Crypto Cloud file
+            NSString *fileName = itemDto.fileName;
+            if (itemDto.isDirectory)
+                fileName = [fileName substringToIndex:[fileName length] - 1];
+                
+            if ([CCUtility isFileCryptated:fileName])
+                continue;
+            
+            // ----- BUG #942 ---------
+            if ([itemDto.etag length] == 0) {
+#ifndef EXTENSION
+                [app messageNotification:@"Server error" description:@"Metadata etag absent, record excluded, please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError];
+#endif
+                continue;
+            }
+            // ------------------------
+            
+            NSString *serverUrl = [NSString stringWithFormat:@"%@/files/%@/", dav, _activeUser];
+            serverUrl = [itemDto.filePath stringByReplacingOccurrencesOfString:serverUrl withString:@""];
+            
+            NSString *directoryID = [CCCoreData addDirectory:serverUrl date:[NSDate date] permissions:itemDto.permissions activeAccount:_metadataNet.account];
+
+            [metadatas addObject:[CCUtility trasformedOCFileToCCMetadata:itemDto fileNamePrint:itemDto.fileName serverUrl:serverUrl directoryID:directoryID cameraFolderName:cameraFolderName cameraFolderPath:cameraFolderPath activeAccount:_metadataNet.account directoryUser:directoryUser]];
+        }
+    
         if ([self.delegate respondsToSelector:@selector(searchSuccess:metadatas:)])
         if ([self.delegate respondsToSelector:@selector(searchSuccess:metadatas:)])
             [self.delegate searchSuccess:_metadataNet metadatas:nil];
             [self.delegate searchSuccess:_metadataNet metadatas:nil];