diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager+Directories.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager+Directories.swift index 0e29754df..62ad0445c 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager+Directories.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager+Directories.swift @@ -28,8 +28,10 @@ extension NextcloudFilesDatabaseManager { of: placeholderSeparator, with: problematicSeparator) if let metadata = ncDatabase().objects(NextcloudItemMetadataTable.self).filter( - "account == %@ AND serverUrl == %@ AND fileName == %@ AND directory == true", account, - directoryItemServerUrl, directoryItemFileName + "account == %@ AND serverUrl == %@ AND fileName == %@ AND directory == true", + account, + directoryItemServerUrl, + directoryItemFileName ).first { return NextcloudItemMetadataTable(value: metadata) } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager.swift index f0344f40b..77d980a78 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudFilesDatabaseManager.swift @@ -123,7 +123,9 @@ class NextcloudFilesDatabaseManager: NSObject { -> [NextcloudItemMetadataTable] { let metadatas = ncDatabase().objects(NextcloudItemMetadataTable.self).filter( - "account == %@ AND serverUrl == %@ AND status == %@", account, serverUrl, + "account == %@ AND serverUrl == %@ AND status == %@", + account, + serverUrl, status.rawValue) return sortedItemMetadatas(metadatas) } @@ -216,7 +218,9 @@ class NextcloudFilesDatabaseManager: NSObject { } func updateItemMetadatas( - account: String, serverUrl: String, updatedMetadatas: [NextcloudItemMetadataTable], + account: String, + serverUrl: String, + updatedMetadatas: [NextcloudItemMetadataTable], updateDirectoryEtags: Bool ) -> ( newMetadatas: [NextcloudItemMetadataTable]?, @@ -227,7 +231,9 @@ class NextcloudFilesDatabaseManager: NSObject { do { let existingMetadatas = database.objects(NextcloudItemMetadataTable.self).filter( - "account == %@ AND serverUrl == %@ AND status == %@", account, serverUrl, + "account == %@ AND serverUrl == %@ AND status == %@", + account, + serverUrl, NextcloudItemMetadataTable.Status.normal.rawValue) let metadatasToDelete = processItemMetadatasToDelete( @@ -249,7 +255,8 @@ class NextcloudFilesDatabaseManager: NSObject { for metadata in directoriesNeedingRename { if let updatedDirectoryChildren = renameDirectoryAndPropagateToChildren( - ocId: metadata.ocId, newServerUrl: metadata.serverUrl, + ocId: metadata.ocId, + newServerUrl: metadata.serverUrl, newFileName: metadata.fileName) { metadatasToUpdate += updatedDirectoryChildren @@ -270,7 +277,8 @@ class NextcloudFilesDatabaseManager: NSObject { } return ( - newMetadatas: metadatasToCreate, updatedMetadatas: metadatasToUpdate, + newMetadatas: metadatasToCreate, + updatedMetadatas: metadatasToUpdate, deletedMetadatas: metadatasToDelete ) } catch { @@ -282,7 +290,8 @@ class NextcloudFilesDatabaseManager: NSObject { } func setStatusForItemMetadata( - _ metadata: NextcloudItemMetadataTable, status: NextcloudItemMetadataTable.Status, + _ metadata: NextcloudItemMetadataTable, + status: NextcloudItemMetadataTable.Status, completionHandler: @escaping (_ updatedMetadata: NextcloudItemMetadataTable?) -> Void ) { let database = ncDatabase() diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudItemMetadataTable+NKFile.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudItemMetadataTable+NKFile.swift index e64818ebc..c54744948 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudItemMetadataTable+NKFile.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudItemMetadataTable+NKFile.swift @@ -104,8 +104,11 @@ extension NextcloudItemMetadataTable { var metadatas: [NextcloudItemMetadataTable] = [] let conversionQueue = DispatchQueue( - label: "nkFileToMetadataConversionQueue", qos: .userInitiated, attributes: .concurrent) - let appendQueue = DispatchQueue(label: "metadataAppendQueue", qos: .userInitiated) // Serial queue + label: "nkFileToMetadataConversionQueue", + qos: .userInitiated, + attributes: .concurrent) + // appendQueue is a serial queue, not concurrent + let appendQueue = DispatchQueue(label: "metadataAppendQueue", qos: .userInitiated) let dispatchGroup = DispatchGroup() for file in files { diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudItemMetadataTable.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudItemMetadataTable.swift index 84ab23e1d..1ba072128 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudItemMetadataTable.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Database/NextcloudItemMetadataTable.swift @@ -94,7 +94,8 @@ class NextcloudItemMetadataTable: Object { @Persisted var sessionSelector = "" @Persisted var sessionTaskIdentifier: Int = 0 @Persisted var sharePermissionsCollaborationServices: Int = 0 - let sharePermissionsCloudMesh = List() // TODO: Find a way to compare these in remote state check + // TODO: Find a way to compare these two below in remote state check + let sharePermissionsCloudMesh = List() let shareType = List() @Persisted var size: Int64 = 0 @Persisted var status: Int = 0 @@ -183,9 +184,12 @@ class NextcloudItemMetadataTable: Object { func isInSameDatabaseStoreableRemoteState(_ comparingMetadata: NextcloudItemMetadataTable) -> Bool { - comparingMetadata.etag == etag && comparingMetadata.fileNameView == fileNameView - && comparingMetadata.date == date && comparingMetadata.permissions == permissions - && comparingMetadata.hasPreview == hasPreview && comparingMetadata.note == note + comparingMetadata.etag == etag + && comparingMetadata.fileNameView == fileNameView + && comparingMetadata.date == date + && comparingMetadata.permissions == permissions + && comparingMetadata.hasPreview == hasPreview + && comparingMetadata.note == note && comparingMetadata.lock == lock && comparingMetadata.sharePermissionsCollaborationServices == sharePermissionsCollaborationServices @@ -203,13 +207,13 @@ class NextcloudItemMetadataTable: Object { } let urlBase = urlBase.urlEncoded! - let webdavUrl = urlBase + NextcloudAccount.webDavFilesUrlSuffix + user // Leave the leading slash + // Leave the leading slash in webdavUrl + let webdavUrl = urlBase + NextcloudAccount.webDavFilesUrlSuffix + user let serverFileRelativeUrl = serverUrl.replacingOccurrences(of: webdavUrl, with: "") + "/" + fileName let urlString = "\(urlBase)/index.php/core/preview.png?file=\(serverFileRelativeUrl)&x=\(size.width)&y=\(size.height)&a=1&mode=cover" - return URL(string: urlString) } } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderEnumerator.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderEnumerator.swift index 4ef7f8e1f..dc6e30621 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderEnumerator.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderEnumerator.swift @@ -23,7 +23,8 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator { FileProviderEnumerator.isSystemIdentifier(enumeratedItemIdentifier) } - private let anchor = NSFileProviderSyncAnchor(Date().description.data(using: .utf8)!) // TODO: actually use this in NCKit and server requests + // TODO: actually use this in NCKit and server requests + private let anchor = NSFileProviderSyncAnchor(Date().description.data(using: .utf8)!) private static let maxItemsPerFileProviderPage = 100 let ncAccount: NextcloudAccount let ncKit: NextcloudKit @@ -35,7 +36,8 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator { } init( - enumeratedItemIdentifier: NSFileProviderItemIdentifier, ncAccount: NextcloudAccount, + enumeratedItemIdentifier: NSFileProviderItemIdentifier, + ncAccount: NextcloudAccount, ncKit: NextcloudKit ) { self.enumeratedItemIdentifier = enumeratedItemIdentifier @@ -317,8 +319,12 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator { ) FileProviderEnumerator.completeChangesObserver( - observer, anchor: anchor, ncKit: self.ncKit, newMetadatas: newMetadatas, - updatedMetadatas: updatedMetadatas, deletedMetadatas: deletedMetadatas) + observer, + anchor: anchor, + ncKit: self.ncKit, + newMetadatas: newMetadatas, + updatedMetadatas: updatedMetadatas, + deletedMetadatas: deletedMetadatas) } } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderItem.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderItem.swift index b571c38d4..9dc4dbbb5 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderItem.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderItem.swift @@ -134,7 +134,8 @@ class FileProviderItem: NSObject, NSFileProviderItem { } required init( - metadata: NextcloudItemMetadataTable, parentItemIdentifier: NSFileProviderItemIdentifier, + metadata: NextcloudItemMetadataTable, + parentItemIdentifier: NSFileProviderItemIdentifier, ncKit: NextcloudKit ) { self.metadata = metadata