Selaa lähdekoodia

add parameter depth in readFolder

Marino Faggiana 7 vuotta sitten
vanhempi
commit
0c4740c4bd

+ 1 - 0
Picker/DocumentPickerViewController.swift

@@ -255,6 +255,7 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
         let metadataNet = CCMetadataNet.init(account: activeAccount)!
 
         metadataNet.action = actionReadFolder
+        metadataNet.depth = "1"
         metadataNet.serverUrl = self.serverUrl
         metadataNet.selector = selectorReadFolder
         

+ 1 - 1
iOSClient/Actions/CCActions.swift

@@ -349,7 +349,7 @@ class CCActions: NSObject {
         metadataNet.delegate = delegate
         metadataNet.directoryID = directoryID
         metadataNet.fileName = fileName
-        metadataNet.options = depth
+        metadataNet.depth = depth
         metadataNet.priority = Operation.QueuePriority.high.rawValue
         metadataNet.selector = selector
         metadataNet.serverUrl = serverUrl

+ 1 - 0
iOSClient/Favorites/CCFavorites.m

@@ -203,6 +203,7 @@
     CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
     
     metadataNet.action = actionReadFolder;
+    metadataNet.depth = @"1";
     metadataNet.directoryID = directoryID;
     
     if ([CCUtility getFavoriteOffline])

+ 1 - 1
iOSClient/Library/OCCommunicationLib/OCCommunication.h

@@ -295,7 +295,7 @@ typedef enum {
  * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  *
  */
-- (void) readFolder: (NSString *) path withUserSessionToken:(NSString *)token
+- (void) readFolder: (NSString *) path depth:(NSString *)depth withUserSessionToken:(NSString *)token
     onCommunication:(OCCommunication *)sharedOCCommunication
      successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token)) successRequest
      failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *token, NSString *redirectedServer)) failureRequest;

+ 2 - 2
iOSClient/Library/OCCommunicationLib/OCCommunication.m

@@ -423,7 +423,7 @@
 ///-----------------------------------
 /// @name Read folder
 ///-----------------------------------
-- (void) readFolder: (NSString *) path withUserSessionToken:(NSString *)token
+- (void) readFolder: (NSString *) path depth:(NSString *)depth withUserSessionToken:(NSString *)token
     onCommunication:(OCCommunication *)sharedOCCommunication
      successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token)) successRequest
      failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *token, NSString *redirectedServer)) failureRequest{
@@ -438,7 +438,7 @@
     request = [self getRequestWithCredentials:request];
     
     
-    [request listPath:path onCommunication:sharedOCCommunication withUserSessionToken:token success:^(NSHTTPURLResponse *response, id responseObject, NSString *token) {
+    [request listPath:path depth:depth onCommunication:sharedOCCommunication withUserSessionToken:token success:^(NSHTTPURLResponse *response, id responseObject, NSString *token) {
         if (successRequest) {
             NSData *responseData = (NSData*) responseObject;
             

+ 2 - 2
iOSClient/Library/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.h

@@ -158,7 +158,7 @@ extern NSString * _Nullable OCWebDAVModificationDateKey;
  @see propertiesOfPath:success:failure:
  @see recursiveListPath:success:failure:
  */
-- (void)listPath:(NSString * _Nonnull)path
+- (void)listPath:(NSString * _Nonnull)path depth:(NSString * _Nonnull)depth
  onCommunication: (OCCommunication * _Nonnull)sharedOCCommunication
          success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject))success
          failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id  _Nullable responseObject, NSError * _Nonnull error))failure;
@@ -178,7 +178,7 @@ extern NSString * _Nullable OCWebDAVModificationDateKey;
  @see propertiesOfPath:success:failure:
  @see recursiveListPath:success:failure:
  */
-- (void)listPath:(NSString * _Nonnull)path
+- (void)listPath:(NSString * _Nonnull)path depth:(NSString * _Nonnull)depth
  onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication withUserSessionToken:(NSString * _Nonnull)token
          success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id  _Nonnull, NSString * _Nonnull token))success
          failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id  _Nullable responseObject, NSError * _Nonnull, NSString * _Nonnull token))failure;

+ 16 - 8
iOSClient/Library/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.m

@@ -58,7 +58,7 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
 
 @interface OCWebDAVClient()
 
-- (void)mr_listPath:(NSString *)path depth:(NSUInteger)depth onCommunication:
+- (void)mr_listPath:(NSString *)path depth:(NSString *)depth onCommunication:
 (OCCommunication *)sharedOCCommunication
             success:(void(^)(NSHTTPURLResponse *, id))success
             failure:(void(^)(NSHTTPURLResponse *, id  _Nullable responseObject, NSError *))failure;
@@ -207,7 +207,7 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
 }
 
 
-- (void)mr_listPath:(NSString *)path depth:(NSUInteger)depth onCommunication:
+- (void)mr_listPath:(NSString *)path depth:(NSString *)depth onCommunication:
 (OCCommunication *)sharedOCCommunication
             success:(void(^)(NSHTTPURLResponse *, id))success
             failure:(void(^)(NSHTTPURLResponse *, id  _Nullable responseObject, NSError *))failure {
@@ -215,6 +215,8 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     
     _requestMethod = @"PROPFIND";
 	NSMutableURLRequest *request = [self requestWithMethod:_requestMethod path:path parameters:nil];
+    
+    /*
 	NSString *depthHeader = nil;
 	if (depth <= 0)
 		depthHeader = @"0";
@@ -223,7 +225,9 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
 	else
 		depthHeader = @"infinity";
     [request setValue: depthHeader forHTTPHeaderField: @"Depth"];
+    */
     
+    [request setValue: depth forHTTPHeaderField: @"Depth"];
     [request setHTTPBody:[@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><D:propfind xmlns:D=\"DAV:\"><D:prop><D:resourcetype/><D:getlastmodified/><size xmlns=\"http://owncloud.org/ns\"/><favorite xmlns=\"http://owncloud.org/ns\"/><D:creationdate/><id xmlns=\"http://owncloud.org/ns\"/><D:getcontentlength/><D:displayname/><D:quota-available-bytes/><D:getetag/><permissions xmlns=\"http://owncloud.org/ns\"/><D:quota-used-bytes/><D:getcontenttype/></D:prop></D:propfind>" dataUsingEncoding:NSUTF8StringEncoding]];
     [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
     
@@ -233,7 +237,7 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     [operation resume];
 }
 
-- (void)mr_listPath:(NSString *)path depth:(NSUInteger)depth withUserSessionToken:(NSString*)token onCommunication:
+- (void)mr_listPath:(NSString *)path depth:(NSString *)depth withUserSessionToken:(NSString*)token onCommunication:
 (OCCommunication *)sharedOCCommunication
             success:(void(^)(NSHTTPURLResponse *operation, id response, NSString *token))success
             failure:(void(^)(NSHTTPURLResponse *response, id  _Nullable responseObject, NSError *, NSString *token))failure {
@@ -241,6 +245,8 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     
     _requestMethod = @"PROPFIND";
     NSMutableURLRequest *request = [self requestWithMethod:_requestMethod path:path parameters:nil];
+    
+    /*
     NSString *depthHeader = nil;
     if (depth <= 0)
         depthHeader = @"0";
@@ -249,7 +255,9 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     else
         depthHeader = @"infinity";
     [request setValue: depthHeader forHTTPHeaderField: @"Depth"];
+    */ 
     
+    [request setValue: depth forHTTPHeaderField: @"Depth"];
     [request setHTTPBody:[@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><D:propfind xmlns:D=\"DAV:\"><D:prop><D:resourcetype/><D:getlastmodified/><size xmlns=\"http://owncloud.org/ns\"/><favorite xmlns=\"http://owncloud.org/ns\"/><D:creationdate/><id xmlns=\"http://owncloud.org/ns\"/><D:getcontentlength/><D:displayname/><D:quota-available-bytes/><D:getetag/><permissions xmlns=\"http://owncloud.org/ns\"/><D:quota-used-bytes/><D:getcontenttype/></D:prop></D:propfind>" dataUsingEncoding:NSUTF8StringEncoding]];
     [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
     
@@ -263,21 +271,21 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
          onCommunication: (OCCommunication *)sharedOCCommunication
                  success:(void(^)(NSHTTPURLResponse *, id ))success
                  failure:(void(^)(NSHTTPURLResponse *, id  _Nullable responseObject, NSError *))failure {
-	[self mr_listPath:path depth:0 onCommunication:sharedOCCommunication success:success failure:failure];
+	[self mr_listPath:path depth:@"0" onCommunication:sharedOCCommunication success:success failure:failure];
 }
 
-- (void)listPath:(NSString *)path
+- (void)listPath:(NSString *)path depth:(NSString *)depth
  onCommunication:(OCCommunication *)sharedOCCommunication
          success:(void(^)(NSHTTPURLResponse *, id))success
          failure:(void(^)(NSHTTPURLResponse *, id  _Nullable responseObject, NSError *))failure {
-	[self mr_listPath:path depth:1 onCommunication:sharedOCCommunication success:success failure:failure];
+	[self mr_listPath:path depth:depth onCommunication:sharedOCCommunication success:success failure:failure];
 }
 
-- (void)listPath:(NSString *)path
+- (void)listPath:(NSString *)path depth:(NSString *)depth
  onCommunication:(OCCommunication *)sharedOCCommunication withUserSessionToken:(NSString *)token
          success:(void(^)(NSHTTPURLResponse *, id, NSString *token))success
          failure:(void(^)(NSHTTPURLResponse *, id  _Nullable responseObject, NSError *, NSString *token))failure {
-    [self mr_listPath:path depth:1 withUserSessionToken:token onCommunication:sharedOCCommunication success:success failure:failure];
+    [self mr_listPath:path depth:depth withUserSessionToken:token onCommunication:sharedOCCommunication success:success failure:failure];
 }
 
 - (void)search:(NSString *)path folder:(NSString *)folder fileName:(NSString *)fileName depth:(NSString *)depth dateLastModified:(NSString *)dateLastModified user:(NSString *)user onCommunication:(OCCommunication *)sharedOCCommunication withUserSessionToken:(NSString *)token success:(void(^)(NSHTTPURLResponse *, id, NSString *token))success failure:(void(^)(NSHTTPURLResponse *, id  _Nullable responseObject, NSError *, NSString *token))failure {

+ 1 - 0
iOSClient/Main/CCMain.m

@@ -2001,6 +2001,7 @@
 
     metadataNet.action = actionReadFolder;
     metadataNet.date = [NSDate date];
+    metadataNet.depth = @"1";
     metadataNet.directoryID = directory.directoryID;
     metadataNet.priority = NSOperationQueuePriorityHigh;
     metadataNet.selector = selectorReadFolder;

+ 3 - 2
iOSClient/Move/CCMove.m

@@ -408,9 +408,10 @@
     CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:activeAccount];
     
     metadataNet.action = actionReadFolder;
-    metadataNet.serverUrl = _serverUrl;
-    metadataNet.selector = selectorReadFolder;
     metadataNet.date = nil;
+    metadataNet.depth = @"1";
+    metadataNet.selector = selectorReadFolder;
+    metadataNet.serverUrl = _serverUrl;
     
     [self addNetworkingQueue:metadataNet];
     

+ 1 - 0
iOSClient/Networking/CCNetworking.h

@@ -96,6 +96,7 @@
 @property BOOL cryptated;
 @property (nonatomic, strong) NSDate *date;
 @property (nonatomic, weak) id delegate;
+@property (nonatomic, strong) NSString *depth;
 @property BOOL directory;
 @property (nonatomic, strong) NSString *directoryID;
 @property (nonatomic, strong) NSString *directoryIDTo;

+ 1 - 0
iOSClient/Networking/CCNetworking.m

@@ -1878,6 +1878,7 @@
     [metadataNet setCryptated: self.cryptated];
     [metadataNet setDate: self.date];
     [metadataNet setDelegate: self.delegate];
+    [metadataNet setDepth: self.depth];
     [metadataNet setDirectory: self.directory];
     [metadataNet setDirectoryID: self.directoryID];
     [metadataNet setDirectoryIDTo: self.directoryIDTo];

+ 2 - 2
iOSClient/Networking/OCNetworking.m

@@ -221,7 +221,7 @@
     [communication setCredentialsWithUser:_activeUser andPassword:_activePassword];
     [communication setUserAgent:[CCUtility getUserAgent]];
     
-    [communication readFolder:_metadataNet.serverUrl withUserSessionToken:nil onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token) {
+    [communication readFolder:_metadataNet.serverUrl depth:_metadataNet.depth withUserSessionToken:nil onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token) {
         
         NSMutableArray *metadatas = [NSMutableArray new];
         BOOL showHiddenFiles = [CCUtility getShowHiddenFiles];
@@ -386,7 +386,7 @@
         dateLastModified = [dateFormatter stringFromDate:_metadataNet.date];
     }
     
-    [communication search:path folder:folder fileName: [NSString stringWithFormat:@"%%%@%%", _metadataNet.fileName] depth:_metadataNet.options dateLastModified:dateLastModified withUserSessionToken:nil onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token) {
+    [communication search:path folder:folder fileName: [NSString stringWithFormat:@"%%%@%%", _metadataNet.fileName] depth:_metadataNet.depth dateLastModified:dateLastModified withUserSessionToken:nil onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token) {
         
         NSMutableArray *metadatas = [NSMutableArray new];
         BOOL showHiddenFiles = [CCUtility getShowHiddenFiles];

+ 1 - 0
iOSClient/Synchronize/CCSynchronize.m

@@ -67,6 +67,7 @@
     NSString *directoryID = [[NCManageDatabase sharedInstance] getDirectoryID:serverUrl];
     if (!directoryID) return;
     
+    metadataNet.depth = @"1";
     metadataNet.directoryID = directoryID;
     metadataNet.priority = NSOperationQueuePriorityLow;
     metadataNet.selector = selector;