mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-25 22:05:53 +03:00
Use pathForFileProviderExtData in NextcloudFilesDatabaseManager
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
730c30f324
commit
83230baeaa
1 changed files with 8 additions and 11 deletions
|
@ -21,7 +21,7 @@ class NextcloudFilesDatabaseManager : NSObject {
|
||||||
return NextcloudFilesDatabaseManager();
|
return NextcloudFilesDatabaseManager();
|
||||||
}()
|
}()
|
||||||
|
|
||||||
let relativeDatabaseFolderPath: String = "FileProviderExt/Database/"
|
let relativeDatabaseFolderPath: String = "Database/"
|
||||||
let databaseFilename: String = "fileproviderextdatabase.realm"
|
let databaseFilename: String = "fileproviderextdatabase.realm"
|
||||||
let relativeDatabaseFilePath: String
|
let relativeDatabaseFilePath: String
|
||||||
var databasePath: URL?
|
var databasePath: URL?
|
||||||
|
@ -31,24 +31,21 @@ class NextcloudFilesDatabaseManager : NSObject {
|
||||||
override init() {
|
override init() {
|
||||||
self.relativeDatabaseFilePath = self.relativeDatabaseFolderPath + self.databaseFilename
|
self.relativeDatabaseFilePath = self.relativeDatabaseFolderPath + self.databaseFilename
|
||||||
|
|
||||||
guard let appGroupIdentifier = Bundle.main.object(forInfoDictionaryKey: "SocketApiPrefix") as? String else {
|
guard let fileProviderDataDirUrl = pathForFileProviderExtData() else {
|
||||||
super.init()
|
super.init()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let containerUrl = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier)
|
self.databasePath = fileProviderDataDirUrl.appendingPathExtension(self.relativeDatabaseFilePath)
|
||||||
self.databasePath = containerUrl?.appendingPathExtension(self.relativeDatabaseFilePath)
|
|
||||||
|
|
||||||
// Disable file protection for directory DB
|
// 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
|
// 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 = fileProviderDataDirUrl.appendingPathComponent(self.relativeDatabaseFolderPath).path
|
||||||
let folderPath = folderPathURL.path
|
|
||||||
do {
|
do {
|
||||||
try FileManager.default.setAttributes([FileAttributeKey.protectionKey: FileProtectionType.completeUntilFirstUserAuthentication], ofItemAtPath: folderPath)
|
try FileManager.default.setAttributes([FileAttributeKey.protectionKey: FileProtectionType.completeUntilFirstUserAuthentication], ofItemAtPath: folderPath)
|
||||||
} catch {
|
} catch {
|
||||||
print("Could not set permission level for File Provider database folder")
|
print("Could not set permission level for File Provider database folder")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let config = Realm.Configuration(
|
let config = Realm.Configuration(
|
||||||
fileURL: self.databasePath,
|
fileURL: self.databasePath,
|
||||||
|
|
Loading…
Reference in a new issue