瀏覽代碼

Merge pull request #2259 from nextcloud/456

Version 4.5.6
Marino Faggiana 2 年之前
父節點
當前提交
2de13b5c98

+ 0 - 1
Cartfile

@@ -1,3 +1,2 @@
 github "https://github.com/marinofaggiana/KTVHTTPCache" "2.0.5"
 github "https://github.com/marinofaggiana/TOPasscodeViewController" "master"
-github "krzyzanowskim/OpenSSL"

+ 0 - 1
Cartfile.resolved

@@ -1,3 +1,2 @@
-github "krzyzanowskim/OpenSSL" "1.1.1700"
 github "marinofaggiana/KTVHTTPCache" "2.0.5"
 github "marinofaggiana/TOPasscodeViewController" "a1b9d1058b2648e636525fc368e220a0cfddb42a"

+ 2 - 2
File Provider Extension/FileProviderExtension+Actions.swift

@@ -37,7 +37,7 @@ extension FileProviderExtension {
         let directoryName = NCUtilityFileSystem.shared.createFileName(directoryName, serverUrl: tableDirectory.serverUrl, account: fileProviderData.shared.account)
         let serverUrlFileName = tableDirectory.serverUrl + "/" + directoryName
 
-        NextcloudKit.shared.createFolder(serverUrlFileName) { account, ocId, _, error in
+        NextcloudKit.shared.createFolder(serverUrlFileName: serverUrlFileName) { account, ocId, _, error in
 
             if error == .success {
 
@@ -88,7 +88,7 @@ extension FileProviderExtension {
         let serverUrl = metadata.serverUrl
         let fileName = metadata.fileName
 
-        NextcloudKit.shared.deleteFileOrFolder(serverUrlFileName) { account, error in
+        NextcloudKit.shared.deleteFileOrFolder(serverUrlFileName: serverUrlFileName) { account, error in
 
             if error == .success { // || error == kOCErrorServerPathNotFound {
 

+ 22 - 11
Nextcloud.xcodeproj/project.pbxproj

@@ -298,6 +298,7 @@
 		F771E3F820E239B500AFB62D /* FileProviderExtension+Thumbnail.swift in Sources */ = {isa = PBXBuildFile; fileRef = F771E3F520E239B400AFB62D /* FileProviderExtension+Thumbnail.swift */; };
 		F7725A60251F33BB00D125E0 /* NCFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7725A5E251F33BB00D125E0 /* NCFiles.swift */; };
 		F7725A61251F33BB00D125E0 /* NCFiles.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7725A5F251F33BB00D125E0 /* NCFiles.storyboard */; };
+		F77333882927A72100466E35 /* OpenSSL in Frameworks */ = {isa = PBXBuildFile; productRef = F77333872927A72100466E35 /* OpenSSL */; };
 		F774264A22EB4D0000B23912 /* NCSearchUserDropDownCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F774264822EB4D0000B23912 /* NCSearchUserDropDownCell.xib */; };
 		F77444F522281649000D5EB0 /* NCGridMediaCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F77444F322281649000D5EB0 /* NCGridMediaCell.swift */; };
 		F77444F622281649000D5EB0 /* NCGridMediaCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F77444F422281649000D5EB0 /* NCGridMediaCell.xib */; };
@@ -466,9 +467,6 @@
 		F7E0710128B13BB00001B882 /* DashboardData.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7E0710028B13BB00001B882 /* DashboardData.swift */; };
 		F7E0CDCF265CE8610044854E /* NCUserStatus.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7E0CDCE265CE8610044854E /* NCUserStatus.storyboard */; };
 		F7E4D9C422ED929B003675FD /* NCShareCommentsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7E4D9C322ED929B003675FD /* NCShareCommentsCell.swift */; };
-		F7E572FD278F146C00F8C99E /* OpenSSL.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = F70B86802642CF5400ED5349 /* OpenSSL.xcframework */; };
-		F7E572FE278F146C00F8C99E /* OpenSSL.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = F70B86802642CF5400ED5349 /* OpenSSL.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
-		F7E57302278F14FF00F8C99E /* OpenSSL.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = F70B86802642CF5400ED5349 /* OpenSSL.xcframework */; };
 		F7E98C1627E0D0FC001F9F19 /* NCManageDatabase+Video.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7E98C1527E0D0FC001F9F19 /* NCManageDatabase+Video.swift */; };
 		F7E98C1727E0D0FC001F9F19 /* NCManageDatabase+Video.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7E98C1527E0D0FC001F9F19 /* NCManageDatabase+Video.swift */; };
 		F7E98C1827E0D0FC001F9F19 /* NCManageDatabase+Video.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7E98C1527E0D0FC001F9F19 /* NCManageDatabase+Video.swift */; };
@@ -563,7 +561,6 @@
 			files = (
 				F76DA942277B75870082465B /* KTVHTTPCache.xcframework in Embed Frameworks */,
 				F76DA95C277B75A90082465B /* TOPasscodeViewController.xcframework in Embed Frameworks */,
-				F7E572FE278F146C00F8C99E /* OpenSSL.xcframework in Embed Frameworks */,
 				F76DA940277B75870082465B /* KTVCocoaHTTPServer.xcframework in Embed Frameworks */,
 			);
 			name = "Embed Frameworks";
@@ -1159,7 +1156,6 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				F7E57302278F14FF00F8C99E /* OpenSSL.xcframework in Frameworks */,
 				F710FC80277B7D2700AA9FBF /* RealmSwift in Frameworks */,
 				F72AD70F28C24BA1006CB92D /* NextcloudKit in Frameworks */,
 				F72CD01227A7E92400E59476 /* JGProgressHUD in Frameworks */,
@@ -1212,8 +1208,8 @@
 				F734B06628E75C0100E180D5 /* TLPhotoPicker in Frameworks */,
 				F770768E263A8C3400A1BA94 /* FloatingPanel in Frameworks */,
 				F710FC7C277B7D0000AA9FBF /* RealmSwift in Frameworks */,
-				F7E572FD278F146C00F8C99E /* OpenSSL.xcframework in Frameworks */,
 				F758A01227A7F03E0069468B /* JGProgressHUD in Frameworks */,
+				F77333882927A72100466E35 /* OpenSSL in Frameworks */,
 				F76DA966277B76F30082465B /* UICKeyChainStore in Frameworks */,
 				F753BA93281FD8020015BFB6 /* EasyTipView in Frameworks */,
 				F76DA95B277B75A90082465B /* TOPasscodeViewController.xcframework in Frameworks */,
@@ -2397,6 +2393,7 @@
 				F753BA92281FD8020015BFB6 /* EasyTipView */,
 				F72AD70C28C24B93006CB92D /* NextcloudKit */,
 				F734B06528E75C0100E180D5 /* TLPhotoPicker */,
+				F77333872927A72100466E35 /* OpenSSL */,
 			);
 			productName = "Crypto Cloud";
 			productReference = F7CE8AFA1DC1F8D8009CAE48 /* Nextcloud.app */;
@@ -2553,6 +2550,7 @@
 				F753BA91281FD8010015BFB6 /* XCRemoteSwiftPackageReference "EasyTipView" */,
 				F783034028B511D200B84583 /* XCRemoteSwiftPackageReference "NextcloudKit" */,
 				F734B06428E75C0100E180D5 /* XCRemoteSwiftPackageReference "TLPhotoPicker" */,
+				F77333862927A72100466E35 /* XCRemoteSwiftPackageReference "OpenSSL" */,
 			);
 			productRefGroup = F7F67B9F1A24D27800EE80DA;
 			projectDirPath = "";
@@ -3619,7 +3617,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 2;
+				CURRENT_PROJECT_VERSION = 4;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
@@ -3643,7 +3641,7 @@
 					"@executable_path/Frameworks",
 					"@executable_path/../../Frameworks",
 				);
-				MARKETING_VERSION = 4.5.5;
+				MARKETING_VERSION = 4.5.6;
 				ONLY_ACTIVE_ARCH = YES;
 				OTHER_LDFLAGS = "";
 				SDKROOT = iphoneos;
@@ -3682,7 +3680,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 2;
+				CURRENT_PROJECT_VERSION = 4;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
@@ -3704,7 +3702,7 @@
 					"@executable_path/Frameworks",
 					"@executable_path/../../Frameworks",
 				);
-				MARKETING_VERSION = 4.5.5;
+				MARKETING_VERSION = 4.5.6;
 				ONLY_ACTIVE_ARCH = YES;
 				OTHER_LDFLAGS = "";
 				SDKROOT = iphoneos;
@@ -3907,12 +3905,20 @@
 				minimumVersion = 2.0.0;
 			};
 		};
+		F77333862927A72100466E35 /* XCRemoteSwiftPackageReference "OpenSSL" */ = {
+			isa = XCRemoteSwiftPackageReference;
+			repositoryURL = "https://github.com/krzyzanowskim/OpenSSL";
+			requirement = {
+				kind = upToNextMajorVersion;
+				minimumVersion = 1.0.0;
+			};
+		};
 		F783034028B511D200B84583 /* XCRemoteSwiftPackageReference "NextcloudKit" */ = {
 			isa = XCRemoteSwiftPackageReference;
 			repositoryURL = "https://github.com/nextcloud/NextcloudKit";
 			requirement = {
 				kind = exactVersion;
-				version = 1.3.0;
+				version = 1.4.0;
 			};
 		};
 		F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {
@@ -4117,6 +4123,11 @@
 			package = F770768C263A8C3400A1BA94 /* XCRemoteSwiftPackageReference "FloatingPanel" */;
 			productName = FloatingPanel;
 		};
+		F77333872927A72100466E35 /* OpenSSL */ = {
+			isa = XCSwiftPackageProductDependency;
+			package = F77333862927A72100466E35 /* XCRemoteSwiftPackageReference "OpenSSL" */;
+			productName = OpenSSL;
+		};
 		F783030428B4C50600B84583 /* SVGKit */ = {
 			isa = XCSwiftPackageProductDependency;
 			package = F75E57A725BF0D61002B72C2 /* XCRemoteSwiftPackageReference "SVGKit" */;

+ 6 - 6
Widget/Lockscreen/LockscreenData.swift

@@ -76,14 +76,14 @@ func getLockscreenDataEntry(configuration: AccountIntent?, isPreview: Bool, fami
     if #available(iOSApplicationExtension 16.0, *) {
         if family == .accessoryCircular {
             NextcloudKit.shared.getUserProfile(options: options) { _, userProfile, _, error in
-                if error == .success, let userProfile = userProfile, let account = NCManageDatabase.shared.setAccountUserProfile(userProfile) {
-                    if account.quotaRelative > 0 {
-                        quotaRelative = Float(account.quotaRelative) / 100
+                if error == .success, let userProfile = userProfile {
+                    if userProfile.quotaRelative > 0 {
+                        quotaRelative = Float(userProfile.quotaRelative) / 100
                     }
-                    let quotaUsed: String = CCUtility.transformedSize(account.quotaUsed)
+                    let quotaUsed: String = CCUtility.transformedSize(userProfile.quotaUsed)
                     var quotaTotal: String = ""
 
-                    switch account.quotaTotal {
+                    switch userProfile.quotaTotal {
                     case -1:
                         quotaTotal = ""
                     case -2:
@@ -91,7 +91,7 @@ func getLockscreenDataEntry(configuration: AccountIntent?, isPreview: Bool, fami
                     case -3:
                         quotaTotal = ""
                     default:
-                        quotaTotal = CCUtility.transformedSize(account.quotaTotal)
+                        quotaTotal = CCUtility.transformedSize(userProfile.quotaTotal)
                     }
                     completion(LockscreenData(date: Date(), isPlaceholder: false, activity: "", link: URL(string: "https://")!, quotaRelative: quotaRelative, quotaUsed: quotaUsed, quotaTotal: quotaTotal, error: false))
                 } else {

+ 6 - 0
iOSClient/Data/NCDataSource.swift

@@ -480,6 +480,7 @@ class NCMetadataForSection: NSObject {
         totalSize = 0
 
         var ocIds: [String] = []
+        let metadataInSession = metadatas.filter({ !$0.session.isEmpty })
 
         // Metadata order
         //
@@ -525,6 +526,11 @@ class NCMetadataForSection: NSObject {
                 continue
             }
 
+            // Upload [REPLACE] skip
+            if metadata.session.isEmpty && !metadataInSession.filter({ $0.fileNameView == metadata.fileNameView }).isEmpty {
+                continue
+            }
+
             // share
             if let share = self.shares.filter({ $0.serverUrl == metadata.serverUrl && $0.fileName == metadata.fileName }).first {
                 metadataShare[metadata.ocId] = share

+ 29 - 71
iOSClient/Data/NCManageDatabase+Account.swift

@@ -79,7 +79,6 @@ extension NCManageDatabase {
         do {
             try realm.write {
                 let result = realm.objects(tableAccount.self).filter("account == %@", account)
-
                 realm.delete(result)
             }
         } catch let error {
@@ -285,88 +284,47 @@ extension NCManageDatabase {
         }
     }
 
-    @objc func setAccountUserProfile(_ userProfile: NKUserProfile) -> tableAccount? {
+    @objc func setAccountUserProfile(account: String, userProfile: NKUserProfile) -> tableAccount? {
 
         let realm = try! Realm()
 
-        var returnAccount = tableAccount()
-
         do {
-            guard let activeAccount = self.getActiveAccount() else {
-                return nil
-            }
-
             try realm.write {
-
-                guard let result = realm.objects(tableAccount.self).filter("account == %@", activeAccount.account).first else {
-                    return
+                if let result = realm.objects(tableAccount.self).filter("account == %@", account).first {
+                    result.address = userProfile.address
+                    result.backend = userProfile.backend
+                    result.backendCapabilitiesSetDisplayName = userProfile.backendCapabilitiesSetDisplayName
+                    result.backendCapabilitiesSetPassword = userProfile.backendCapabilitiesSetPassword
+                    result.displayName = userProfile.displayName
+                    result.email = userProfile.email
+                    result.enabled = userProfile.enabled
+                    result.groups = userProfile.groups.joined(separator: ",")
+                    result.language = userProfile.language
+                    result.lastLogin = userProfile.lastLogin
+                    result.locale = userProfile.locale
+                    result.organisation = userProfile.organisation
+                    result.phone = userProfile.phone
+                    result.quota = userProfile.quota
+                    result.quotaFree = userProfile.quotaFree
+                    result.quotaRelative = userProfile.quotaRelative
+                    result.quotaTotal = userProfile.quotaTotal
+                    result.quotaUsed = userProfile.quotaUsed
+                    result.storageLocation = userProfile.storageLocation
+                    result.subadmin = userProfile.subadmin.joined(separator: ",")
+                    result.twitter = userProfile.twitter
+                    result.userId = userProfile.userId
+                    result.website = userProfile.website
                 }
-
-                result.address = userProfile.address
-                result.backend = userProfile.backend
-                result.backendCapabilitiesSetDisplayName = userProfile.backendCapabilitiesSetDisplayName
-                result.backendCapabilitiesSetPassword = userProfile.backendCapabilitiesSetPassword
-                result.displayName = userProfile.displayName
-                result.email = userProfile.email
-                result.enabled = userProfile.enabled
-                result.groups = userProfile.groups.joined(separator: ",")
-                result.language = userProfile.language
-                result.lastLogin = userProfile.lastLogin
-                result.locale = userProfile.locale
-                result.organisation = userProfile.organisation
-                result.phone = userProfile.phone
-                result.quota = userProfile.quota
-                result.quotaFree = userProfile.quotaFree
-                result.quotaRelative = userProfile.quotaRelative
-                result.quotaTotal = userProfile.quotaTotal
-                result.quotaUsed = userProfile.quotaUsed
-                result.storageLocation = userProfile.storageLocation
-                result.subadmin = userProfile.subadmin.joined(separator: ",")
-                result.twitter = userProfile.twitter
-                result.userId = userProfile.userId
-                result.website = userProfile.website
-
-                returnAccount = result
             }
         } catch let error {
             NKCommon.shared.writeLog("Could not write to database: \(error)")
         }
 
-        return tableAccount.init(value: returnAccount)
-    }
-
-    @objc func setAccountUserProfileHC(businessSize: String, businessType: String, city: String, organisation: String, country: String, role: String, zip: String) -> tableAccount? {
-
-        let realm = try! Realm()
-
-        var returnAccount = tableAccount()
-
-        do {
-            guard let activeAccount = self.getActiveAccount() else {
-                return nil
-            }
-
-            try realm.write {
-
-                guard let result = realm.objects(tableAccount.self).filter("account == %@", activeAccount.account).first else {
-                    return
-                }
-
-                result.businessSize = businessSize
-                result.businessType = businessType
-                result.city = city
-                result.organisation =  organisation
-                result.country = country
-                result.role = role
-                result.zip = zip
-
-                returnAccount = result
-            }
-        } catch let error {
-            NKCommon.shared.writeLog("Could not write to database: \(error)")
+        if let result = realm.objects(tableAccount.self).filter("account == %@", account).first {
+            return tableAccount.init(value: result)
+        } else {
+            return nil
         }
-
-        return tableAccount.init(value: returnAccount)
     }
 
     @objc func setAccountMediaPath(_ path: String, account: String) {

+ 4 - 4
iOSClient/Data/NCManageDatabase.swift

@@ -1283,10 +1283,9 @@ class NCManageDatabase: NSObject {
     // MARK: -
     // MARK: Table Share
 
-    @objc func addShare(account: String, urlBase: String, userId: String, shares: [NKShare]) {
+    @objc func addShare(account: String, home: String, shares: [NKShare]) {
 
         let realm = try! Realm()
-        let home = NCUtilityFileSystem.shared.getHomeServer(urlBase: urlBase, userId: userId)
 
         do {
             try realm.write {
@@ -1297,12 +1296,13 @@ class NCManageDatabase: NSObject {
                     guard let serverUrl = NCUtilityFileSystem.shared.deleteLastPath(serverUrlPath: serverUrlPath, home: home) else {
                         continue
                     }
-                    let fileName = NSString(string: serverUrlPath).lastPathComponent
 
                     let object = tableShare()
 
                     object.account = account
-                    object.fileName = fileName
+                    if let fileName = share.path.components(separatedBy: "/").last {
+                        object.fileName = fileName
+                    }
                     object.serverUrl = serverUrl
 
                     object.canEdit = share.canEdit

+ 2 - 2
iOSClient/Networking/NCNetworking.swift

@@ -973,7 +973,7 @@ import Photos
         }
         let fileNameFolderUrl = serverUrl + "/" + fileNameFolder
 
-        NextcloudKit.shared.createFolder(fileNameFolderUrl) { account, ocId, _, error in
+        NextcloudKit.shared.createFolder(serverUrlFileName: fileNameFolderUrl) { account, ocId, _, error in
             guard error == .success else {
                 if error.errorCode == NCGlobal.shared.errordMethodNotSupported && overwrite {
                     completion(NKError())
@@ -1125,7 +1125,7 @@ import Photos
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
         let options = NKRequestOptions(customHeader: customHeader)
         
-        NextcloudKit.shared.deleteFileOrFolder(serverUrlFileName, options: options) { account, error in
+        NextcloudKit.shared.deleteFileOrFolder(serverUrlFileName: serverUrlFileName, options: options) { account, error in
 
             if error == .success || error.errorCode == NCGlobal.shared.errorResourceNotFound {
 

+ 3 - 3
iOSClient/Networking/NCNetworkingChunkedUpload.swift

@@ -216,7 +216,7 @@ extension NCNetworking {
             if error == .success {
                 completion(NKError())
             } else if error.errorCode == NCGlobal.shared.errorResourceNotFound {
-                NextcloudKit.shared.createFolder(chunkFolderPath, options: options) { _, _, _, error in
+                NextcloudKit.shared.createFolder(serverUrlFileName: chunkFolderPath, options: options) { _, _, _, error in
                     completion(error)
                 }
             } else {
@@ -234,13 +234,13 @@ extension NCNetworking {
         if error.errorCode == NSURLErrorCancelled || error.errorCode == NCGlobal.shared.errorRequestExplicityCancelled {
 
             // Delete chunk folder
-            NextcloudKit.shared.deleteFileOrFolder(chunkFolderPath) { _, _ in }
+            NextcloudKit.shared.deleteFileOrFolder(serverUrlFileName: chunkFolderPath) { _, _ in }
 
             NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
             NCManageDatabase.shared.deleteChunks(account: metadata.account, ocId: metadata.ocId)
             NCUtilityFileSystem.shared.deleteFile(filePath: directoryProviderStorageOcId)
 
-            NextcloudKit.shared.deleteFileOrFolder(chunkFolderPath) { _, _ in }
+            NextcloudKit.shared.deleteFileOrFolder(serverUrlFileName: chunkFolderPath) { _, _ in }
 
             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadCancelFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account])
 

+ 1 - 1
iOSClient/Networking/NCNetworkingE2EE.swift

@@ -53,7 +53,7 @@ import Alamofire
 
                 let options = NKRequestOptions(customHeader: ["e2e-token": e2eToken!])
                 
-                NextcloudKit.shared.createFolder(fileNameFolderUrl, options: options) { account, ocId, _, error in
+                NextcloudKit.shared.createFolder(serverUrlFileName: fileNameFolderUrl, options: options) { account, ocId, _, error in
                     if error == .success {
                         guard let fileId = NCUtility.shared.ocIdToFileId(ocId: ocId) else {
                             // unlock

+ 6 - 7
iOSClient/Networking/NCService.swift

@@ -109,7 +109,7 @@ class NCService: NSObject {
         let options = NKRequestOptions(queue: NKCommon.shared.backgroundQueue)
 
         NextcloudKit.shared.getUserProfile(options: options) { account, userProfile, data, error in
-            guard error == .success, account == self.appDelegate.account else {
+            guard error == .success, let userProfile = userProfile else {
                 
                 // Ops the server has Unauthorized
                 NKCommon.shared.writeLog("[ERROR] The server has response with Unauthorized \(error.errorCode)")
@@ -127,7 +127,7 @@ class NCService: NSObject {
             }
 
             // Update User (+ userProfile.id) & active account & account network
-            guard let tableAccount = NCManageDatabase.shared.setAccountUserProfile(userProfile!) else {
+            guard let tableAccount = NCManageDatabase.shared.setAccountUserProfile(account: account, userProfile: userProfile) else {
                 let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "Internal error : account not found on DB")
                 NCContentPresenter.shared.showError(error: error, priority: .max)
                 return
@@ -195,19 +195,18 @@ class NCService: NSObject {
             // File Sharing
             let isFilesSharingEnabled = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
             if isFilesSharingEnabled {
-                NextcloudKit.shared.readShares(parameters: NKShareParameter(), options: options) { account, shares, data, error in
-                    if error == .success {
+                NextcloudKit.shared.readShares(parameters: NKShareParameter()) { account, shares, data, error in
+                    if error == .success, let tableAccount = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)) {
                         NCManageDatabase.shared.deleteTableShare(account: account)
                         if let shares = shares, !shares.isEmpty {
-                            NCManageDatabase.shared.addShare(account: self.appDelegate.account, urlBase: self.appDelegate.urlBase, userId: self.appDelegate.userId, shares: shares)
+                            let home = NCUtilityFileSystem.shared.getHomeServer(urlBase: tableAccount.urlBase, userId: tableAccount.userId)
+                            NCManageDatabase.shared.addShare(account: account, home: home, shares: shares)
                         }
                     }
                 }
             }
-
             let comments = NCManageDatabase.shared.getCapabilitiesServerBool(account: account, elements: NCElementsJSON.shared.capabilitiesFilesComments, exists: false)
             let activity = NCManageDatabase.shared.getCapabilitiesServerArray(account: account, elements: NCElementsJSON.shared.capabilitiesActivity)
-
             if !isFilesSharingEnabled && !comments && activity == nil {
                 self.appDelegate.disableSharesView = true
             } else {

+ 6 - 3
iOSClient/Share/NCShareNetworking.swift

@@ -52,7 +52,8 @@ class NCShareNetworking: NSObject {
             }
 
             if error == .success, let shares = shares {
-                NCManageDatabase.shared.addShare(account: self.metadata.account, urlBase: self.metadata.urlBase, userId: self.metadata.userId, shares: shares)
+                let home = NCUtilityFileSystem.shared.getHomeServer(urlBase: self.metadata.urlBase, userId: self.metadata.userId)
+                NCManageDatabase.shared.addShare(account: self.metadata.account, home:home, shares: shares)
             } else {
                 NCContentPresenter.shared.showError(error: error)
             }
@@ -75,7 +76,8 @@ class NCShareNetworking: NSObject {
             NCActivityIndicator.shared.stop()
             if error == .success, let share = share {
                 option.idShare = share.idShare
-                NCManageDatabase.shared.addShare(account: self.metadata.account, urlBase: self.metadata.urlBase, userId: self.metadata.userId, shares: [share])
+                let home = NCUtilityFileSystem.shared.getHomeServer(urlBase: self.metadata.urlBase, userId: self.metadata.userId)
+                NCManageDatabase.shared.addShare(account: self.metadata.account, home: home, shares: [share])
                 if option.hasChanges(comparedTo: share) {
                     self.updateShare(option: option)
                 }
@@ -104,7 +106,8 @@ class NCShareNetworking: NSObject {
         NextcloudKit.shared.updateShare(idShare: option.idShare, password: option.password, expireDate: option.expDateString, permissions: option.permissions, note: option.note, label: option.label, hideDownload: option.hideDownload) { account, share, data, error in
             NCActivityIndicator.shared.stop()
             if error == .success, let share = share {
-                NCManageDatabase.shared.addShare(account: self.metadata.account, urlBase: self.metadata.urlBase, userId: self.metadata.userId, shares: [share])
+                let home = NCUtilityFileSystem.shared.getHomeServer(urlBase: self.metadata.urlBase, userId: self.metadata.userId)
+                NCManageDatabase.shared.addShare(account: self.metadata.account, home: home, shares: [share])
                 self.delegate?.readShareCompleted()
             } else {
                 NCContentPresenter.shared.showError(error: error)

+ 2 - 1
iOSClient/Shares/NCShares.swift

@@ -100,7 +100,8 @@ class NCShares: NCCollectionViewCommon {
             if error == .success {
                 NCManageDatabase.shared.deleteTableShare(account: account)
                 if let shares = shares, !shares.isEmpty {
-                    NCManageDatabase.shared.addShare(account: self.appDelegate.account, urlBase: self.appDelegate.urlBase, userId: self.appDelegate.userId, shares: shares)
+                    let home = NCUtilityFileSystem.shared.getHomeServer(urlBase: self.appDelegate.urlBase, userId: self.appDelegate.userId)
+                    NCManageDatabase.shared.addShare(account: self.appDelegate.account, home: home, shares: shares)
                 }
                 self.reloadDataSource()
 

+ 2 - 2
iOSClient/Trash/NCTrash.swift

@@ -316,7 +316,7 @@ extension NCTrash {
 
         let serverUrlFileName = appDelegate.urlBase + "/" + NCGlobal.shared.dav + "/trashbin/" + appDelegate.userId + "/trash"
 
-        NextcloudKit.shared.deleteFileOrFolder(serverUrlFileName) { account, error in
+        NextcloudKit.shared.deleteFileOrFolder(serverUrlFileName: serverUrlFileName) { account, error in
 
             guard error == .success, account == self.appDelegate.account else {
                 NCContentPresenter.shared.showError(error: error)
@@ -333,7 +333,7 @@ extension NCTrash {
         guard let tableTrash = NCManageDatabase.shared.getTrashItem(fileId: fileId, account: appDelegate.account) else { return }
         let serverUrlFileName = tableTrash.filePath + tableTrash.fileName
 
-        NextcloudKit.shared.deleteFileOrFolder(serverUrlFileName) { account, error in
+        NextcloudKit.shared.deleteFileOrFolder(serverUrlFileName: serverUrlFileName) { account, error in
 
             guard error == .success, account == self.appDelegate.account else {
                 NCContentPresenter.shared.showError(error: error)

+ 1 - 10
iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift

@@ -29,7 +29,6 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     var webView = WKWebView()
     var bottomConstraint: NSLayoutConstraint?
-
     var link: String = ""
     var editor: String = ""
     var metadata: tableMetadata = tableMetadata()
@@ -84,9 +83,9 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
 
         appDelegate.activeViewController = self
 
-        //
         NotificationCenter.default.addObserver(self, selector: #selector(favoriteFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterFavoriteFile), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(viewUnload), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterMenuDetailClose), object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(viewUnload), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidEnterBackground), object: nil)
 
         NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow), name: UIResponder.keyboardDidShowNotification, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
@@ -95,12 +94,6 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
 
-        if let navigationController = self.navigationController {
-            if !navigationController.viewControllers.contains(self) {
-            }
-        }
-
-        //
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterFavoriteFile), object: nil)
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterMenuDetailClose), object: nil)
 
@@ -109,7 +102,6 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
     }
 
     @objc func viewUnload() {
-
         navigationController?.popViewController(animated: true)
     }
 
@@ -136,7 +128,6 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
     }
 
     @objc func keyboardWillHide(notification: Notification) {
-
         bottomConstraint?.constant = 0
     }
 

+ 6 - 12
iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift

@@ -31,7 +31,6 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess
     var webView = WKWebView()
     var bottomConstraint: NSLayoutConstraint?
     var documentController: UIDocumentInteractionController?
-
     var link: String = ""
     var metadata: tableMetadata = tableMetadata()
     var imageIcon: UIImage?
@@ -45,6 +44,11 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess
     override func viewDidLoad() {
         super.viewDidLoad()
 
+        navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "more")!.image(color: .label, size: 25), style: .plain, target: self, action: #selector(self.openMenuMore))
+
+        navigationController?.navigationBar.prefersLargeTitles = false
+        navigationItem.title = metadata.fileNameView
+
         let config = WKWebViewConfiguration()
         config.websiteDataStore = WKWebsiteDataStore.nonPersistent()
         let contentController = config.userContentController
@@ -76,21 +80,14 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess
 
         appDelegate.activeViewController = self
 
-        //
         NotificationCenter.default.addObserver(self, selector: #selector(favoriteFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterFavoriteFile), object: nil)
 
         NotificationCenter.default.addObserver(self, selector: #selector(viewUnload), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterMenuDetailClose), object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(viewUnload), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidEnterBackground), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(self.grabFocus), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterRichdocumentGrabFocus), object: nil)
 
         NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow), name: UIResponder.keyboardDidShowNotification, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
-
-        //
-        navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "more")!.image(color: .label, size: 25), style: .plain, target: self, action: #selector(self.openMenuMore))
-
-        navigationItem.hidesBackButton = true
-        navigationController?.navigationBar.prefersLargeTitles = false
-        navigationItem.title = metadata.fileNameView
     }
 
     override func viewWillDisappear(_ animated: Bool) {
@@ -105,7 +102,6 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess
             }
         }
 
-        //
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterFavoriteFile), object: nil)
 
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterMenuDetailClose), object: nil)
@@ -116,7 +112,6 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess
     }
 
     @objc func viewUnload() {
-
         navigationController?.popViewController(animated: true)
     }
 
@@ -143,7 +138,6 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess
     }
 
     @objc func keyboardWillHide(notification: Notification) {
-
         bottomConstraint?.constant = 0
     }