|
@@ -300,7 +300,7 @@
|
|
|
returnToken = token;
|
|
|
[[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithFileID:fileID token:returnToken];
|
|
|
|
|
|
- // REMOVE METADATA
|
|
|
+ // DELETE METADATA
|
|
|
[communication deleteEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
NSLog(@"Found metadata and delete");
|
|
|
} failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
@@ -486,4 +486,65 @@
|
|
|
return returnError;
|
|
|
}
|
|
|
|
|
|
+- (NSError *)rebuildEndToEndMetadata:(NSString *)user userID:(NSString *)userID password:(NSString *)password url:(NSString *)url fileID:(NSString *)fileID metadata:(NSString *)metadata token:(NSString **)token
|
|
|
+{
|
|
|
+ OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
|
|
|
+
|
|
|
+ __block NSError *returnError = nil;
|
|
|
+ __block NSString *returnToken = nil;
|
|
|
+
|
|
|
+ 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:*token onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ returnToken = token;
|
|
|
+ [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithFileID:fileID token:returnToken];
|
|
|
+
|
|
|
+ // DELETE METADATA
|
|
|
+ [communication deleteEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ // STORE METADATA
|
|
|
+ [communication storeEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID encryptedMetadata:metadata onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *encryptedMetadata, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ // UNLOCK
|
|
|
+ [communication unlockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:returnToken onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ returnToken = nil;
|
|
|
+ [[NCManageDatabase sharedInstance] setDirectoryE2ETokenLockWithFileID:fileID token:@""];
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Unlock folder error %lu", (unsigned long)response.statusCode] forKey:NSLocalizedDescriptionKey]];
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ }];
|
|
|
+
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Store metadata error %lu", (unsigned long)response.statusCode] forKey:NSLocalizedDescriptionKey]];
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ }];
|
|
|
+
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Update metadata error %lu", (unsigned long)response.statusCode] forKey:NSLocalizedDescriptionKey]];
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ }];
|
|
|
+
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Lock folder error %lu", (unsigned long)response.statusCode] forKey:NSLocalizedDescriptionKey]];
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ }];
|
|
|
+
|
|
|
+ while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
|
|
|
+ [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
|
|
|
+
|
|
|
+ return returnError;
|
|
|
+}
|
|
|
+
|
|
|
@end
|