Marino Faggiana 1 year ago
parent
commit
e298eaf62b

+ 1 - 1
iOSClient/Data/NCManageDatabase+Metadata.swift

@@ -232,7 +232,7 @@ extension tableMetadata {
     }
 
     @objc var isDirectoryE2EE: Bool {
-        NCUtility.shared.isDirectoryE2EE(serverUrl: serverUrl, account: account, urlBase: urlBase, userId: userId)
+        NCUtility.shared.isDirectoryE2EE(account: account, urlBase: urlBase, userId: userId, serverUrl: serverUrl)
     }
 
     /// Returns false if the user is lokced out of the file. I.e. The file is locked but by somone else

+ 3 - 2
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -39,6 +39,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     internal var backgroundImageView = UIImageView()
     internal var serverUrl: String = ""
     internal var isDirectoryE2EE = false
+    internal var isDirectoryE2EETop = false
     internal var isEditMode = false
     internal var selectOcId: [String] = []
     internal var selectIndexPath: [IndexPath] = []
@@ -53,7 +54,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
     private var autoUploadFileName = ""
     private var autoUploadDirectory = ""
-
     internal var groupByField = "name"
     internal var providers: [NKSearchProvider]?
     internal var searchResults: [NKSearchResult]?
@@ -955,6 +955,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
         // E2EE
         isDirectoryE2EE = NCUtility.shared.isDirectoryE2EE(serverUrl: serverUrl, userBase: appDelegate)
+        isDirectoryE2EETop =  NCUtility.shared.isDirectoryE2EETop(account: appDelegate.account, serverUrl: serverUrl)
         // get auto upload folder
         autoUploadFileName = NCManageDatabase.shared.getAccountAutoUploadFileName()
         autoUploadDirectory = NCManageDatabase.shared.getAccountAutoUploadDirectory(urlBase: appDelegate.urlBase, userId: appDelegate.userId, account: appDelegate.account)
@@ -1622,7 +1623,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         }
 
         // Disable Share Button
-        if appDelegate.disableSharesView {
+        if appDelegate.disableSharesView || (isDirectoryE2EE && !isDirectoryE2EETop ) {
             cell.hideButtonShare(true)
         }
 

+ 1 - 1
iOSClient/Networking/E2EE/NCEndToEndMetadataV20.swift

@@ -38,7 +38,7 @@ extension NCEndToEndMetadata {
             return (nil, nil)
         }
 
-        let isDirectoryTop = NCUtility.shared.isDirectoryE2EETop(serverUrl: serverUrl, account: account)
+        let isDirectoryTop = NCUtility.shared.isDirectoryE2EETop(account: account, serverUrl: serverUrl)
         var metadataKey: String?
         var keyChecksums: [String] = []
         var usersCodable: [E2eeV20.Users] = []

+ 1 - 1
iOSClient/Networking/NCNetworking.swift

@@ -1150,7 +1150,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
     func createFolder(fileName: String, serverUrl: String, account: String, urlBase: String, userId: String, overwrite: Bool = false, withPush:Bool, completion: @escaping (_ error: NKError) -> Void) {
 
-        let isDirectoryEncrypted = NCUtility.shared.isDirectoryE2EE(serverUrl: serverUrl, account: account, urlBase: urlBase, userId: userId)
+        let isDirectoryEncrypted = NCUtility.shared.isDirectoryE2EE(account: account, urlBase: urlBase, userId: userId, serverUrl: serverUrl)
         let fileName = fileName.trimmingCharacters(in: .whitespacesAndNewlines)
         
         if isDirectoryEncrypted {

+ 4 - 4
iOSClient/Utility/NCUtility.swift

@@ -748,14 +748,14 @@ class NCUtility: NSObject {
     }
 
     func isDirectoryE2EE(serverUrl: String, userBase: NCUserBaseUrl) -> Bool {
-        return isDirectoryE2EE(serverUrl: serverUrl, account: userBase.account, urlBase: userBase.urlBase, userId: userBase.userId)
+        return isDirectoryE2EE(account: userBase.account, urlBase: userBase.urlBase, userId: userBase.userId, serverUrl: serverUrl)
     }
 
     func isDirectoryE2EE(file: NKFile) -> Bool {
-        return isDirectoryE2EE(serverUrl: file.serverUrl, account: file.account, urlBase: file.urlBase, userId: file.userId)
+        return isDirectoryE2EE(account: file.account, urlBase: file.urlBase, userId: file.userId, serverUrl: file.serverUrl)
     }
 
-    func isDirectoryE2EE(serverUrl: String, account: String, urlBase: String, userId: String) -> Bool {
+    func isDirectoryE2EE(account: String, urlBase: String, userId: String, serverUrl: String) -> Bool {
         if serverUrl == NCUtilityFileSystem.shared.getHomeServer(urlBase: urlBase, userId: userId) || serverUrl == ".." { return false }
         if let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", account, serverUrl)) {
             return directory.e2eEncrypted
@@ -763,7 +763,7 @@ class NCUtility: NSObject {
         return false
     }
 
-    func isDirectoryE2EETop(serverUrl: String, account: String) -> Bool {
+    func isDirectoryE2EETop(account: String, serverUrl: String) -> Bool {
         if let url = URL(string: serverUrl)?.deletingLastPathComponent() {
             if let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", account, String(url.absoluteString.dropLast()))) {
                 return !directory.e2eEncrypted