Forráskód Böngészése

downloadPreviewTrashWithFileID add account

Marino Faggiana 6 éve
szülő
commit
3d53024f45

+ 3 - 1
iOSClient/Main/CCDetail.m

@@ -401,7 +401,9 @@
                     self.navigationItem.titleView = nil;
                     self.title = metadata.fileNameView;
                     
-                    [self.photoBrowser reloadData];
+                    if ([metadata.account isEqualToString:appDelegate.activeAccount] && errorCode == 0) {
+                        [self.photoBrowser reloadData];
+                    }
                 }];
             } else {
                 [self downloadPhotoBrowser:metadata];

+ 8 - 6
iOSClient/Main/NCMainCommon.swift

@@ -1169,12 +1169,14 @@ class NCNetworkingMain: NSObject, CCNetworkingDelegate {
             let ocNetworking = OCnetworking.init(delegate: self, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
             
             ocNetworking?.downloadPreview(with: metadata, withWidth: width, andHeight: height, completion: { (message, errorCode) in
-                if errorCode == 0 && CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) {
-                    if view is UICollectionView && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
-                        (view as! UICollectionView).reloadItems(at: [indexPath])
-                    }
-                    if view is UITableView && CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
-                        (view as! UITableView).reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
+                if metadata.account == self.appDelegate.activeAccount {
+                    if errorCode == 0 && CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) {
+                        if view is UICollectionView && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
+                            (view as! UICollectionView).reloadItems(at: [indexPath])
+                        }
+                        if view is UITableView && CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) && NCMainCommon.sharedInstance.isValidIndexPath(indexPath, view: view) {
+                            (view as! UITableView).reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
+                        }
                     }
                 }
             })

+ 1 - 1
iOSClient/Media/CCMedia.m

@@ -608,7 +608,7 @@
     
     [ocNetworking downloadPreviewWithMetadata:metadata withWidth:width andHeight:height completion:^(NSString *message, NSInteger errorCode) {
         counterThumbnail--;
-        if (errorCode == 0 && [[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]] && [self indexPathIsValid:indexPath] && !collectionViewReloadDataInProgress) {
+        if (errorCode == 0 && [metadata.account isEqualToString:appDelegate.activeAccount] && [[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]] && [self indexPathIsValid:indexPath] && !collectionViewReloadDataInProgress) {
             [self.collectionView reloadItemsAtIndexPaths:@[indexPath]];
         }
     }];

+ 2 - 2
iOSClient/Networking/OCNetworking.h

@@ -51,9 +51,9 @@
 
 - (NSURLSessionTask *)uploadFileNameServerUrl:(NSString *)fileNameServerUrl fileNameLocalPath:(NSString *)fileNameLocalPath communication:(OCCommunication *)communication success:(void(^)(NSString *fileID, NSString *etag, NSDate *date))success failure:(void (^)(NSString *message, NSInteger errorCode))failure;
 
-- (void)downloadThumbnailWithMetadata:(tableMetadata*)metadata withWidth:(CGFloat)width andHeight:(CGFloat)height completion:(void (^)(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)downloadPreviewTrashWithFileID:(NSString *)fileID fileName:(NSString *)fileName completion:(void (^)(NSString *message, NSInteger errorCode))completion;
+- (void)downloadPreviewTrashWithFileID:(NSString *)fileID fileName:(NSString *)fileName account:(NSString *)account completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion;
 
 - (void)readFolder:(NSString *)serverUrl depth:(NSString *)depth account:(NSString *)account success:(void(^)(NSArray *metadatas, tableMetadata *metadataFolder))success failure:(void (^)(NSString *message, NSInteger errorCode))failure;
 

+ 13 - 6
iOSClient/Networking/OCNetworking.m

@@ -399,6 +399,7 @@
 #pragma mark ===== downloadThumbnail / downloadPreview =====
 #pragma --------------------------------------------------------------------------------------------
 
+/*
 - (void)downloadThumbnailWithMetadata:(tableMetadata*)metadata withWidth:(CGFloat)width andHeight:(CGFloat)height completion:(void (^)(NSString *message, NSInteger errorCode))completion
 {
     NSString *file = [NSString stringWithFormat:@"%@/%@.ico", [CCUtility getDirectoryProviderStorageFileID:metadata.fileID], metadata.fileNameView];
@@ -438,27 +439,33 @@
         }];
     }
 }
+*/
 
-- (void)downloadPreviewTrashWithFileID:(NSString *)fileID fileName:(NSString *)fileName completion:(void (^)(NSString *message, NSInteger errorCode))completion
+- (void)downloadPreviewTrashWithFileID:(NSString *)fileID fileName:(NSString *)fileName account:(NSString *)account completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion
 {
     NSString *file = [NSString stringWithFormat:@"%@/%@.ico", [CCUtility getDirectoryProviderStorageFileID:fileID], fileName];
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
+    if (tableAccount == nil) {
+     
+        completion(account, NSLocalizedString(@"_error_user_not_available_", nil), k_CCErrorUserNotAvailble);
+    }
     
     if ([[NSFileManager defaultManager] fileExistsAtPath:file]) {
         
-        completion(nil, 0);
+        completion(account, nil, 0);
         
     } else {
         
         OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
         
-        [communication setCredentialsWithUser:_activeUser andUserID:_activeUserID andPassword:_activePassword];
+        [communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:tableAccount.password];
         [communication setUserAgent:[CCUtility getUserAgent]];
         
-        [communication getRemotePreviewTrashByServer:_activeUrl ofFileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSData *preview, NSString *redirectedServer) {
+        [communication getRemotePreviewTrashByServer:tableAccount.url ofFileID:fileID 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) {
             
@@ -474,7 +481,7 @@
             else
                 message = [error.userInfo valueForKey:@"NSLocalizedDescription"];
             
-            completion(message, errorCode);
+            completion(account, message, errorCode);
         }];
     }
 }

+ 1 - 1
iOSClient/PeekPop/CCPeekPop.m

@@ -102,7 +102,7 @@
     
     [ocNetworking downloadPreviewWithMetadata:_metadata withWidth:width andHeight:height completion:^(NSString *message, NSInteger errorCode) {
         
-        if (errorCode == 0) {
+        if (errorCode == 0 && [_metadata.account isEqualToString:appDelegate.activeAccount]) {
             
             UIImage *image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", [CCUtility getDirectoryProviderStorageFileID:_metadata.fileID], _metadata.fileNameView]];
             

+ 3 - 3
iOSClient/Trash/NCTrash.swift

@@ -544,10 +544,10 @@ class NCTrash: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
     
     func downloadThumbnail(with tableTrash: tableTrash, indexPath: IndexPath) {
                 
-        let ocNetworking = OCnetworking.init(delegate: self, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
+        let ocNetworking = OCnetworking.init(delegate: self, metadataNet: nil, withUser: "", withUserID: "", withPassword: "", withUrl: "")
         
-        ocNetworking?.downloadPreviewTrash(withFileID: tableTrash.fileID, fileName: tableTrash.fileName, completion: { (message, errorCode) in
-            if errorCode == 0 && CCUtility.fileProviderStorageIconExists(tableTrash.fileID, fileNameView: tableTrash.fileName) {
+        ocNetworking?.downloadPreviewTrash(withFileID: tableTrash.fileID, fileName: tableTrash.fileName, account: appDelegate.activeAccount, completion: { (account, message, errorCode) in
+            if errorCode == 0 && account == self.appDelegate.activeAccount && CCUtility.fileProviderStorageIconExists(tableTrash.fileID, fileNameView: tableTrash.fileName) {
                 self.collectionView.reloadItems(at: [indexPath])
             }
         })