mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-25 22:05:53 +03:00
Fix path handling for file provider database setup
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
e7e985f355
commit
f01b6a545f
1 changed files with 10 additions and 8 deletions
|
@ -22,8 +22,8 @@ class NextcloudFilesDatabaseManager : NSObject {
|
||||||
return NextcloudFilesDatabaseManager();
|
return NextcloudFilesDatabaseManager();
|
||||||
}()
|
}()
|
||||||
|
|
||||||
let relativeDatabaseFolderPath: String = "Database/"
|
let relativeDatabaseFolderPath = "Database/"
|
||||||
let databaseFilename: String = "fileproviderextdatabase.realm"
|
let databaseFilename = "fileproviderextdatabase.realm"
|
||||||
let relativeDatabaseFilePath: String
|
let relativeDatabaseFilePath: String
|
||||||
var databasePath: URL?
|
var databasePath: URL?
|
||||||
|
|
||||||
|
@ -37,15 +37,17 @@ class NextcloudFilesDatabaseManager : NSObject {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
self.databasePath = fileProviderDataDirUrl.appendingPathExtension(self.relativeDatabaseFilePath)
|
self.databasePath = fileProviderDataDirUrl.appendingPathComponent(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
|
||||||
let folderPath = fileProviderDataDirUrl.appendingPathComponent(self.relativeDatabaseFolderPath).path
|
let dbFolder = fileProviderDataDirUrl.appendingPathComponent(self.relativeDatabaseFolderPath)
|
||||||
|
let dbFolderPath = dbFolder.path
|
||||||
do {
|
do {
|
||||||
try FileManager.default.setAttributes([FileAttributeKey.protectionKey: FileProtectionType.completeUntilFirstUserAuthentication], ofItemAtPath: folderPath)
|
try FileManager.default.createDirectory(at: dbFolder, withIntermediateDirectories: true)
|
||||||
} catch {
|
try FileManager.default.setAttributes([FileAttributeKey.protectionKey: FileProtectionType.completeUntilFirstUserAuthentication], ofItemAtPath: dbFolderPath)
|
||||||
NSLog("Could not set permission level for File Provider database folder")
|
} catch let error {
|
||||||
|
NSLog("Could not set permission level for File Provider database folder, received error: %@", error.localizedDescription)
|
||||||
}
|
}
|
||||||
|
|
||||||
let config = Realm.Configuration(
|
let config = Realm.Configuration(
|
||||||
|
|
Loading…
Reference in a new issue