|
@@ -222,71 +222,72 @@
|
|
|
OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
|
|
|
|
|
|
__block NSError *returnError = nil;
|
|
|
- __block NSString *tokenDatabase = [[NCManageDatabase sharedInstance] getDirectoryE2ETokenLockWithServerUrl:serverUrl];
|
|
|
|
|
|
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
|
|
|
|
|
[communication setCredentialsWithUser:user andUserID:userID andPassword:password];
|
|
|
[communication setUserAgent:[CCUtility getUserAgent]];
|
|
|
|
|
|
- // Read Folder
|
|
|
- [communication readFolder:serverUrl depth:@"1" withUserSessionToken:nil onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *tokenReadFolder) {
|
|
|
+ [[NCManageDatabase sharedInstance] getDirectoryE2ETokenLockWithServerUrl:serverUrl completion:^(NSString * _Nullable tokenDatabase) {
|
|
|
+
|
|
|
+ // Read Folder
|
|
|
+ [communication readFolder:serverUrl depth:@"1" withUserSessionToken:nil onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *tokenReadFolder) {
|
|
|
|
|
|
- if (items.count > 1) {
|
|
|
+ if (items.count > 1) {
|
|
|
|
|
|
- returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:999 userInfo:[NSDictionary dictionaryWithObject:NSLocalizedString(@"_e2e_error_directory_not_empty_", nil) forKey:NSLocalizedDescriptionKey]];
|
|
|
- dispatch_semaphore_signal(semaphore);
|
|
|
- return;
|
|
|
- }
|
|
|
+ returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:999 userInfo:[NSDictionary dictionaryWithObject:NSLocalizedString(@"_e2e_error_directory_not_empty_", nil) forKey:NSLocalizedDescriptionKey]];
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- // LOCK
|
|
|
- [communication lockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:tokenDatabase onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
|
|
|
+ // LOCK
|
|
|
+ [communication lockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:tokenDatabase onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
|
|
|
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithServerUrl:serverUrl token:token];
|
|
|
- });
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithServerUrl:serverUrl token:token];
|
|
|
+ });
|
|
|
|
|
|
- // REMOVE METADATA
|
|
|
- [communication deleteEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
- NSLog(@"[LOG] Found metadata and delete");
|
|
|
- } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
- NSLog(@"[LOG] %@", [NSString stringWithFormat:@"Remove metadata error %d", (int)response.statusCode]);
|
|
|
- }];
|
|
|
+ // REMOVE METADATA
|
|
|
+ [communication deleteEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
+ NSLog(@"[LOG] Found metadata and delete");
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+ NSLog(@"[LOG] %@", [NSString stringWithFormat:@"Remove metadata error %d", (int)response.statusCode]);
|
|
|
+ }];
|
|
|
|
|
|
- // MARK
|
|
|
- [communication markEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
+ // MARK
|
|
|
+ [communication markEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
|
|
|
- // UNLOCK
|
|
|
- [communication unlockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:token onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
+ // UNLOCK
|
|
|
+ [communication unlockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:token onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithServerUrl:serverUrl token:@""];
|
|
|
- });
|
|
|
- dispatch_semaphore_signal(semaphore);
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithServerUrl:serverUrl token:@""];
|
|
|
+ });
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
|
|
|
- } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
|
|
|
- returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_unlock_"];
|
|
|
+ returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_unlock_"];
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ }];
|
|
|
+
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_mark_folder_"];
|
|
|
dispatch_semaphore_signal(semaphore);
|
|
|
}];
|
|
|
-
|
|
|
+
|
|
|
} failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
-
|
|
|
- returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_mark_folder_"];
|
|
|
+
|
|
|
+ returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_lock_"];
|
|
|
dispatch_semaphore_signal(semaphore);
|
|
|
}];
|
|
|
|
|
|
- } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *token, NSString *redirectedServer) {
|
|
|
|
|
|
- returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_lock_"];
|
|
|
+ returnError = [self getError:response error:error descriptionDefault:@"_error_"];
|
|
|
dispatch_semaphore_signal(semaphore);
|
|
|
}];
|
|
|
-
|
|
|
- } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *token, NSString *redirectedServer) {
|
|
|
-
|
|
|
- returnError = [self getError:response error:error descriptionDefault:@"_error_"];
|
|
|
- dispatch_semaphore_signal(semaphore);
|
|
|
-
|
|
|
}];
|
|
|
|
|
|
while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
|
|
@@ -300,73 +301,74 @@
|
|
|
OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
|
|
|
|
|
|
__block NSError *returnError = nil;
|
|
|
- __block NSString *tokenDatabase = [[NCManageDatabase sharedInstance] getDirectoryE2ETokenLockWithServerUrl:serverUrl];
|
|
|
|
|
|
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
|
|
|
|
|
[communication setCredentialsWithUser:user andUserID:userID andPassword:password];
|
|
|
[communication setUserAgent:[CCUtility getUserAgent]];
|
|
|
|
|
|
- // Read Folder
|
|
|
- [communication readFolder:serverUrl depth:@"1" withUserSessionToken:nil onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *tokenReadFolder) {
|
|
|
+ [[NCManageDatabase sharedInstance] getDirectoryE2ETokenLockWithServerUrl:serverUrl completion:^(NSString * _Nullable tokenDatabase) {
|
|
|
+
|
|
|
+ // Read Folder
|
|
|
+ [communication readFolder:serverUrl depth:@"1" withUserSessionToken:nil onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *tokenReadFolder) {
|
|
|
|
|
|
- if (items.count > 1) {
|
|
|
+ if (items.count > 1) {
|
|
|
|
|
|
- returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:999 userInfo:[NSDictionary dictionaryWithObject:NSLocalizedString(@"_e2e_error_directory_not_empty_", nil) forKey:NSLocalizedDescriptionKey]];
|
|
|
- dispatch_semaphore_signal(semaphore);
|
|
|
- return;
|
|
|
- }
|
|
|
+ returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:999 userInfo:[NSDictionary dictionaryWithObject:NSLocalizedString(@"_e2e_error_directory_not_empty_", nil) forKey:NSLocalizedDescriptionKey]];
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- // LOCK
|
|
|
- [communication lockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:tokenDatabase onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
|
|
|
+ // LOCK
|
|
|
+ [communication lockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:tokenDatabase onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
|
|
|
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithServerUrl:serverUrl token:token];
|
|
|
- });
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithServerUrl:serverUrl token:token];
|
|
|
+ });
|
|
|
|
|
|
- // DELETE METADATA
|
|
|
- [communication deleteEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
- NSLog(@"[LOG] Found metadata and delete");
|
|
|
- } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
- NSLog(@"[LOG] %@", [NSString stringWithFormat:@"Remove metadata error %d", (int)response.statusCode]);
|
|
|
- }];
|
|
|
+ // DELETE METADATA
|
|
|
+ [communication deleteEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
+ NSLog(@"[LOG] Found metadata and delete");
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+ NSLog(@"[LOG] %@", [NSString stringWithFormat:@"Remove metadata error %d", (int)response.statusCode]);
|
|
|
+ }];
|
|
|
|
|
|
- // DELETE MARK
|
|
|
- [communication deletemarkEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
+ // DELETE MARK
|
|
|
+ [communication deletemarkEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
|
|
|
- // UNLOCK
|
|
|
- [communication unlockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:token onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
+ // UNLOCK
|
|
|
+ [communication unlockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:token onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithServerUrl:serverUrl token:@""];
|
|
|
- });
|
|
|
- dispatch_semaphore_signal(semaphore);
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithServerUrl:serverUrl token:@""];
|
|
|
+ });
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
|
|
|
- } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
|
|
|
- returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_unlock_"];
|
|
|
+ returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_unlock_"];
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ }];
|
|
|
+
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_delete_mark_folder_"];
|
|
|
dispatch_semaphore_signal(semaphore);
|
|
|
}];
|
|
|
-
|
|
|
+
|
|
|
} failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
-
|
|
|
- returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_delete_mark_folder_"];
|
|
|
+
|
|
|
+ returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_lock_"];
|
|
|
dispatch_semaphore_signal(semaphore);
|
|
|
}];
|
|
|
-
|
|
|
-
|
|
|
- } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
-
|
|
|
- returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_lock_"];
|
|
|
- dispatch_semaphore_signal(semaphore);
|
|
|
- }];
|
|
|
|
|
|
- } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *token, NSString *redirectedServer) {
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *token, NSString *redirectedServer) {
|
|
|
|
|
|
- returnError = [self getError:response error:error descriptionDefault:@"_error_"];
|
|
|
- dispatch_semaphore_signal(semaphore);
|
|
|
+ returnError = [self getError:response error:error descriptionDefault:@"_error_"];
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ }];
|
|
|
}];
|
|
|
-
|
|
|
+
|
|
|
while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
|
|
|
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
|
|
|
|
|
@@ -435,37 +437,39 @@
|
|
|
OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
|
|
|
|
|
|
__block NSError *returnError = nil;
|
|
|
- __block NSString *tokenDatabase = [[NCManageDatabase sharedInstance] getDirectoryE2ETokenLockWithServerUrl:serverUrl];
|
|
|
|
|
|
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
|
|
|
|
|
[communication setCredentialsWithUser:user andUserID:userID andPassword:password];
|
|
|
[communication setUserAgent:[CCUtility getUserAgent]];
|
|
|
|
|
|
- // LOCK
|
|
|
- [communication lockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:tokenDatabase onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
|
|
|
+ [[NCManageDatabase sharedInstance] getDirectoryE2ETokenLockWithServerUrl:serverUrl completion:^(NSString * _Nullable tokenDatabase) {
|
|
|
+
|
|
|
+ // LOCK
|
|
|
+ [communication lockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:tokenDatabase onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
|
|
|
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithServerUrl:serverUrl token:token];
|
|
|
- });
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithServerUrl:serverUrl token:token];
|
|
|
+ });
|
|
|
|
|
|
- // STORE METADATA
|
|
|
- [communication storeEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID encryptedMetadata:metadata onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *encryptedMetadata, NSString *redirectedServer) {
|
|
|
+ // STORE METADATA
|
|
|
+ [communication storeEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID encryptedMetadata:metadata onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *encryptedMetadata, NSString *redirectedServer) {
|
|
|
|
|
|
- dispatch_semaphore_signal(semaphore);
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
|
|
|
- } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
|
|
|
- returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_store_metadata_"];
|
|
|
- dispatch_semaphore_signal(semaphore);
|
|
|
- }];
|
|
|
+ returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_store_metadata_"];
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ }];
|
|
|
|
|
|
- } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
|
|
|
- returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_lock_"];
|
|
|
- dispatch_semaphore_signal(semaphore);
|
|
|
+ returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_lock_"];
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ }];
|
|
|
}];
|
|
|
-
|
|
|
+
|
|
|
while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
|
|
|
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
|
|
|
|
|
@@ -477,37 +481,39 @@
|
|
|
OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
|
|
|
|
|
|
__block NSError *returnError = nil;
|
|
|
- __block NSString *tokenDatabase = [[NCManageDatabase sharedInstance] getDirectoryE2ETokenLockWithServerUrl:serverUrl];
|
|
|
|
|
|
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
|
|
|
|
|
[communication setCredentialsWithUser:user andUserID:userID andPassword:password];
|
|
|
[communication setUserAgent:[CCUtility getUserAgent]];
|
|
|
|
|
|
- // LOCK
|
|
|
- [communication lockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:tokenDatabase onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
|
|
|
+ [[NCManageDatabase sharedInstance] getDirectoryE2ETokenLockWithServerUrl:serverUrl completion:^(NSString * _Nullable tokenDatabase) {
|
|
|
+
|
|
|
+ // LOCK
|
|
|
+ [communication lockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:tokenDatabase onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
|
|
|
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithServerUrl:serverUrl token:token];
|
|
|
- });
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithServerUrl:serverUrl token:token];
|
|
|
+ });
|
|
|
|
|
|
- // UPDATA METADATA
|
|
|
- [communication updateEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID encryptedMetadata:metadata token:token onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *encryptedMetadata, NSString *redirectedServer) {
|
|
|
+ // UPDATA METADATA
|
|
|
+ [communication updateEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID encryptedMetadata:metadata token:token onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *encryptedMetadata, NSString *redirectedServer) {
|
|
|
|
|
|
- dispatch_semaphore_signal(semaphore);
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
|
|
|
- } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
|
|
|
- returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_update_metadata_"];
|
|
|
- dispatch_semaphore_signal(semaphore);
|
|
|
- }];
|
|
|
+ returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_update_metadata_"];
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ }];
|
|
|
|
|
|
- } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
|
|
|
- returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_lock_"];
|
|
|
- dispatch_semaphore_signal(semaphore);
|
|
|
+ returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_lock_"];
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ }];
|
|
|
}];
|
|
|
-
|
|
|
+
|
|
|
while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
|
|
|
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
|
|
|
|
|
@@ -519,28 +525,30 @@
|
|
|
OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
|
|
|
|
|
|
__block NSError *returnError = nil;
|
|
|
- __block NSString *tokenDatabase = [[NCManageDatabase sharedInstance] getDirectoryE2ETokenLockWithServerUrl:serverUrl];
|
|
|
|
|
|
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
|
|
|
|
|
[communication setCredentialsWithUser:user andUserID:userID andPassword:password];
|
|
|
[communication setUserAgent:[CCUtility getUserAgent]];
|
|
|
|
|
|
- // LOCK
|
|
|
- [communication lockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:tokenDatabase onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
|
|
|
+ [[NCManageDatabase sharedInstance] getDirectoryE2ETokenLockWithServerUrl:serverUrl completion:^(NSString * _Nullable tokenDatabase) {
|
|
|
+
|
|
|
+ // LOCK
|
|
|
+ [communication lockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:tokenDatabase onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
|
|
|
|
|
|
- // Write DB token
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithServerUrl:serverUrl token:token];
|
|
|
- });
|
|
|
- dispatch_semaphore_signal(semaphore);
|
|
|
+ // Write DB token
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithServerUrl:serverUrl token:token];
|
|
|
+ });
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
|
|
|
- } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
|
|
|
- returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_lock_"];
|
|
|
- dispatch_semaphore_signal(semaphore);
|
|
|
+ returnError = [self getError:response error:error descriptionDefault:@"_e2e_error_lock_"];
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ }];
|
|
|
}];
|
|
|
-
|
|
|
+
|
|
|
while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
|
|
|
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
|
|
|
|