From 8e90f6691868e2e7adc28eee998947302d37cc30 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 10 Jan 2023 17:58:00 +0100 Subject: [PATCH] Add getFileMetadataFromOcId method to NextcloudFilesDatabaseManager Signed-off-by: Claudio Cambra --- .../FileProviderExt/NextcloudFilesDatabaseManager.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudFilesDatabaseManager.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudFilesDatabaseManager.swift index 7aa29e0fe..1cfa53c5c 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudFilesDatabaseManager.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudFilesDatabaseManager.swift @@ -26,7 +26,6 @@ class NextcloudFilesDatabaseManager : NSObject { var databasePath: URL? let schemaVersion: UInt64 = 100 - var validDatabase: Bool = false override init() { self.relativeDatabaseFilePath = self.relativeDatabaseFolderPath + self.databaseFilename @@ -61,11 +60,16 @@ class NextcloudFilesDatabaseManager : NSObject { do { let realm = try Realm() print("Successfully started Realm db for FileProviderExt") - self.validDatabase = true } catch let error as NSError { print("Error opening Realm db: %@", error.localizedDescription) } super.init() } + + func getFileMetadataFromOcId(ocId: String) -> NextcloudFileMetadataTable? { + let realm = try! Realm() + realm.refresh() + return realm.objects(NextcloudFileMetadataTable.self).filter("ocId == %@", ocId).first + } } -- 2.30.2