]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Use pathForFileProviderExtData in NextcloudFilesDatabaseManager
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 12 Jan 2023 15:51:44 +0000 (16:51 +0100)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 12 May 2023 05:21:11 +0000 (13:21 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudFilesDatabaseManager.swift

index a554a5c8d5a927b563fb383c7efc283d3c330c13..2e115bb93c76f84fd8a8b2b80f8e3c533e8deb19 100644 (file)
@@ -21,7 +21,7 @@ class NextcloudFilesDatabaseManager : NSObject {
         return NextcloudFilesDatabaseManager();
     }()
 
-    let relativeDatabaseFolderPath: String = "FileProviderExt/Database/"
+    let relativeDatabaseFolderPath: String = "Database/"
     let databaseFilename: String = "fileproviderextdatabase.realm"
     let relativeDatabaseFilePath: String
     var databasePath: URL?
@@ -31,23 +31,20 @@ class NextcloudFilesDatabaseManager : NSObject {
     override init() {
         self.relativeDatabaseFilePath = self.relativeDatabaseFolderPath + self.databaseFilename
 
-        guard let appGroupIdentifier = Bundle.main.object(forInfoDictionaryKey: "SocketApiPrefix") as? String else {
+        guard let fileProviderDataDirUrl = pathForFileProviderExtData() else {
             super.init()
             return
         }
 
-        let containerUrl = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier)
-        self.databasePath = containerUrl?.appendingPathExtension(self.relativeDatabaseFilePath)
+        self.databasePath = fileProviderDataDirUrl.appendingPathExtension(self.relativeDatabaseFilePath)
 
         // Disable file protection for directory DB
         // https://docs.mongodb.com/realm/sdk/ios/examples/configure-and-open-a-realm/#std-label-ios-open-a-local-realm
-        if let folderPathURL = containerUrl?.appendingPathComponent(self.relativeDatabaseFolderPath) {
-            let folderPath = folderPathURL.path
-            do {
-                try FileManager.default.setAttributes([FileAttributeKey.protectionKey: FileProtectionType.completeUntilFirstUserAuthentication], ofItemAtPath: folderPath)
-            } catch {
-                print("Could not set permission level for File Provider database folder")
-            }
+        let folderPath = fileProviderDataDirUrl.appendingPathComponent(self.relativeDatabaseFolderPath).path
+        do {
+            try FileManager.default.setAttributes([FileAttributeKey.protectionKey: FileProtectionType.completeUntilFirstUserAuthentication], ofItemAtPath: folderPath)
+        } catch {
+            print("Could not set permission level for File Provider database folder")
         }
 
         let config = Realm.Configuration(