소스 검색

fix

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 년 전
부모
커밋
54db52e953

+ 2 - 2
Nextcloud.xcodeproj/project.pbxproj

@@ -3617,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 = 3;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
@@ -3680,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 = 3;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;

+ 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

+ 4 - 5
iOSClient/Networking/NCService.swift

@@ -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()