Marino Faggiana 6 gadi atpakaļ
vecāks
revīzija
54c179ee9e

+ 3 - 3
File Provider Extension/FileProviderExtension+Thumbnail.swift

@@ -47,9 +47,9 @@ extension FileProviderExtension {
                     let height = NCUtility.sharedInstance.getScreenHeightForPreview()
                     
                     let ocNetworking = OCnetworking.init(delegate: nil, metadataNet: nil, withUser: nil, withUserID: nil, withPassword: nil, withUrl: nil)
-                    ocNetworking?.downloadPreview(with: metadata!, withWidth: width, andHeight: height, completion: { (message, errorCode) in
-                        
-                        if errorCode == 0 && metadata!.account == self.providerData.account {
+                    ocNetworking?.downloadPreview(withAccount: providerData.account, metadata: metadata, withWidth: width, andHeight: height, completion: { (account, message, errorCode) in
+                       
+                        if errorCode == 0 && account == self.providerData.account {
                             do {
                                 let url = URL.init(fileURLWithPath: CCUtility.getDirectoryProviderStorageIconFileID(metadata!.fileID, fileNameView: metadata!.fileNameView))
                                 let data = try Data.init(contentsOf: url)

+ 3 - 3
iOSClient/Main/CCDetail.m

@@ -400,12 +400,12 @@
                 CGFloat height = [[NCUtility sharedInstance] getScreenHeightForPreview];
 
                 OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:nil withUserID:nil withPassword:nil withUrl:nil];
-                [ocNetworking downloadPreviewWithMetadata:metadata withWidth:width andHeight:height completion:^(NSString *message, NSInteger errorCode) {
-                    
+                [ocNetworking downloadPreviewWithAccount:appDelegate.activeAccount metadata:metadata withWidth:width andHeight:height completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+
                     self.navigationItem.titleView = nil;
                     self.title = metadata.fileNameView;
                     
-                    if ([metadata.account isEqualToString:appDelegate.activeAccount] && errorCode == 0) {
+                    if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
                         [self.photoBrowser reloadData];
                     }
                 }];

+ 4 - 3
iOSClient/Main/NCMainCommon.swift

@@ -1170,9 +1170,10 @@ class NCNetworkingMain: NSObject, CCNetworkingDelegate {
             let height = NCUtility.sharedInstance.getScreenHeightForPreview()
             
             let ocNetworking = OCnetworking.init(delegate: self, metadataNet: nil, withUser: nil, withUserID: nil, withPassword: nil, withUrl: nil)
-            ocNetworking?.downloadPreview(with: metadata, withWidth: width, andHeight: height, completion: { (message, errorCode) in
-                if metadata.account == self.appDelegate.activeAccount {
-                    if errorCode == 0 && CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) {
+            ocNetworking?.downloadPreview(withAccount: appDelegate.activeAccount, metadata: metadata, withWidth: width, andHeight: height, completion: { (account, message, errorCode) in
+              
+                if errorCode == 0 && account == self.appDelegate.activeAccount {
+                    if CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) {
                         if view is UICollectionView && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
                             (view as! UICollectionView).reloadItems(at: [indexPath])
                         }

+ 3 - 2
iOSClient/Media/CCMedia.m

@@ -605,9 +605,10 @@
     CGFloat height = [[NCUtility sharedInstance] getScreenHeightForPreview];
     
     OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:nil withUserID:nil withPassword:nil withUrl:nil];
-    [ocNetworking downloadPreviewWithMetadata:metadata withWidth:width andHeight:height completion:^(NSString *message, NSInteger errorCode) {
+    [ocNetworking downloadPreviewWithAccount:appDelegate.activeAccount metadata:metadata withWidth:width andHeight:height completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+        
         counterThumbnail--;
-        if (errorCode == 0 && [metadata.account isEqualToString:appDelegate.activeAccount] && [[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]] && [self indexPathIsValid:indexPath] && !collectionViewReloadDataInProgress) {
+        if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount] && [[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]] && [self indexPathIsValid:indexPath] && !collectionViewReloadDataInProgress) {
             [self.collectionView reloadItemsAtIndexPaths:@[indexPath]];
         }
     }];

+ 2 - 1
iOSClient/Networking/OCNetworking.h

@@ -52,7 +52,8 @@
 - (NSURLSessionTask *)uploadWithAccount:(NSString *)account fileNameServerUrl:(NSString *)fileNameServerUrl fileNameLocalPath:(NSString *)fileNameLocalPath communication:(OCCommunication *)communication completion:(void(^)(NSString *account, NSString *fileID, NSString *etag, NSDate *date, NSString *message, NSInteger errorCode))completion;
 
 //- (void)downloadThumbnailWithMetadata:(tableMetadata*)metadata withWidth:(CGFloat)width andHeight:(CGFloat)height completion:(void (^)(NSString *message, NSInteger errorCode))completion;
-- (void)downloadPreviewWithMetadata:(tableMetadata*)metadata withWidth:(CGFloat)width andHeight:(CGFloat)height completion:(void (^)(NSString *message, NSInteger errorCode))completion;
+- (void)downloadPreviewWithAccount:(NSString *)account metadata:(tableMetadata*)metadata withWidth:(CGFloat)width andHeight:(CGFloat)height completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion;
+
 - (void)downloadPreviewTrashWithAccount:(NSString *)account FileID:(NSString *)fileID fileName:(NSString *)fileName completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion;
 
 - (void)readFolderWithAccount:(NSString *)account serverUrl:(NSString *)serverUrl depth:(NSString *)depth completion:(void(^)(NSString *account, NSArray *metadatas, tableMetadata *metadataFolder, NSString *message, NSInteger errorCode))completion;

+ 8 - 9
iOSClient/Networking/OCNetworking.m

@@ -502,30 +502,29 @@
     }
 }
 
-- (void)downloadPreviewWithMetadata:(tableMetadata*)metadata withWidth:(CGFloat)width andHeight:(CGFloat)height completion:(void (^)(NSString *message, NSInteger errorCode))completion
+- (void)downloadPreviewWithAccount:(NSString *)account metadata:(tableMetadata*)metadata withWidth:(CGFloat)width andHeight:(CGFloat)height completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion
 {
-    NSString *file = [NSString stringWithFormat:@"%@/%@.ico", [CCUtility getDirectoryProviderStorageFileID:metadata.fileID], metadata.fileNameView];
-    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", metadata.account]];
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
     if (tableAccount == nil) {
-        
-        completion(NSLocalizedString(@"_error_user_not_available_", nil), k_CCErrorUserNotAvailble);
+        completion(account, NSLocalizedString(@"_error_user_not_available_", nil), k_CCErrorUserNotAvailble);
     }
     
     OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
 
     [communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:tableAccount.password];
     [communication setUserAgent:[CCUtility getUserAgent]];
-        
+    
+    NSString *file = [NSString stringWithFormat:@"%@/%@.ico", [CCUtility getDirectoryProviderStorageFileID:metadata.fileID], metadata.fileNameView];
+    
     [communication getRemotePreviewByServer:tableAccount.url ofFilePath:[CCUtility returnFileNamePathFromFileName:metadata.fileName serverUrl:metadata.serverUrl activeUrl:tableAccount.url] withWidth:width andHeight:height andA:1 andMode:@"cover" onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSData *preview, NSString *redirectedServer) {
 
         [preview writeToFile:file atomically:YES];
             
-        completion(nil, 0);
+        completion(account, nil, 0);
             
     } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
             
         NSString *message;
-            
         NSInteger errorCode = response.statusCode;
         if (errorCode == 0 || (errorCode >= 200 && errorCode < 300))
             errorCode = error.code;
@@ -536,7 +535,7 @@
         else
             message = [error.userInfo valueForKey:@"NSLocalizedDescription"];
             
-        completion(message, errorCode);
+        completion(account, message, errorCode);
     }];
 }
 

+ 3 - 3
iOSClient/PeekPop/CCPeekPop.m

@@ -99,9 +99,9 @@
     CGFloat height = [[NCUtility sharedInstance] getScreenHeightForPreview];
     
     OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:nil withUserID:nil withPassword:nil withUrl:nil];
-    [ocNetworking downloadPreviewWithMetadata:_metadata withWidth:width andHeight:height completion:^(NSString *message, NSInteger errorCode) {
-        
-        if (errorCode == 0 && [_metadata.account isEqualToString:appDelegate.activeAccount]) {
+    [ocNetworking downloadPreviewWithAccount:appDelegate.activeAccount metadata:_metadata withWidth:width andHeight:height completion:^(NSString *account, NSString *message, NSInteger errorCode) {
+     
+        if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             
             UIImage *image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", [CCUtility getDirectoryProviderStorageFileID:_metadata.fileID], _metadata.fileNameView]];