From 9018d06a5ec22d2ca1be627d47332f089008da07 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 26 Jul 2024 20:52:15 +0800 Subject: [PATCH 1/6] Remove use of ncaccount in enumerator sync engine methods --- .../Enumeration/Enumerator+SyncEngine.swift | 21 +++++++------------ .../Enumeration/Enumerator.swift | 4 +--- .../Item/Item+Create.swift | 6 +----- .../Item/Item+Fetch.swift | 5 +---- .../Item/Item+Modify.swift | 10 ++------- 5 files changed, 13 insertions(+), 33 deletions(-) diff --git a/Sources/NextcloudFileProviderKit/Enumeration/Enumerator+SyncEngine.swift b/Sources/NextcloudFileProviderKit/Enumeration/Enumerator+SyncEngine.swift index 07ca685..47ba602 100644 --- a/Sources/NextcloudFileProviderKit/Enumeration/Enumerator+SyncEngine.swift +++ b/Sources/NextcloudFileProviderKit/Enumeration/Enumerator+SyncEngine.swift @@ -18,7 +18,6 @@ import OSLog extension Enumerator { func fullRecursiveScan( - ncAccount: Account, remoteInterface: RemoteInterface, dbManager: FilesDatabaseManager, scanChangesOnly: Bool @@ -35,7 +34,6 @@ extension Enumerator { let results = await self.scanRecursively( rootContainerDirectoryMetadata, - ncAccount: ncAccount, remoteInterface: remoteInterface, dbManager: dbManager, scanChangesOnly: scanChangesOnly @@ -67,7 +65,6 @@ extension Enumerator { private func scanRecursively( _ directoryMetadata: ItemMetadata, - ncAccount: Account, remoteInterface: RemoteInterface, dbManager: FilesDatabaseManager, scanChangesOnly: Bool @@ -92,7 +89,7 @@ extension Enumerator { let itemServerUrl = directoryMetadata.ocId == NSFileProviderItemIdentifier.rootContainer.rawValue - ? ncAccount.davFilesUrl + ? remoteInterface.account.davFilesUrl : directoryMetadata.serverUrl + "/" + directoryMetadata.fileName Self.logger.debug("About to read: \(itemServerUrl, privacy: .public)") @@ -101,7 +98,6 @@ extension Enumerator { metadatas, newMetadatas, updatedMetadatas, deletedMetadatas, readError ) = await Self.readServerUrl( itemServerUrl, - ncAccount: ncAccount, remoteInterface: remoteInterface, dbManager: dbManager, domain: domain, @@ -160,7 +156,7 @@ extension Enumerator { Self.logger.info( """ Finished reading serverUrl: \(itemServerUrl, privacy: .public) - for user: \(ncAccount.ncKitAccount, privacy: .public) + for user: \(remoteInterface.account.ncKitAccount, privacy: .public) """ ) @@ -170,7 +166,7 @@ extension Enumerator { Self.logger.warning( """ Nil metadatas received in change read at \(itemServerUrl, privacy: .public) - for user: \(ncAccount.ncKitAccount, privacy: .public) + for user: \(remoteInterface.account.ncKitAccount, privacy: .public) """ ) } @@ -181,7 +177,7 @@ extension Enumerator { Self.logger.warning( """ Nil new metadatas received in change read at \(itemServerUrl, privacy: .public) - for user: \(ncAccount.ncKitAccount, privacy: .public) + for user: \(remoteInterface.account.ncKitAccount, privacy: .public) """ ) } @@ -192,7 +188,7 @@ extension Enumerator { Self.logger.warning( """ Nil updated metadatas received in change read at \(itemServerUrl, privacy: .public) - for user: \(ncAccount.ncKitAccount, privacy: .public) + for user: \(remoteInterface.account.ncKitAccount, privacy: .public) """ ) } @@ -203,7 +199,7 @@ extension Enumerator { Self.logger.warning( """ Nil deleted metadatas received in change read at \(itemServerUrl, privacy: .public) - for user: \(ncAccount.ncKitAccount, privacy: .public) + for user: \(remoteInterface.account.ncKitAccount, privacy: .public) """ ) } @@ -246,7 +242,6 @@ extension Enumerator { ) let childScanResult = await scanRecursively( childDirectory, - ncAccount: ncAccount, remoteInterface: remoteInterface, dbManager: dbManager, scanChangesOnly: scanChangesOnly @@ -323,7 +318,6 @@ extension Enumerator { static func readServerUrl( _ serverUrl: String, - ncAccount: Account, remoteInterface: RemoteInterface, dbManager: FilesDatabaseManager, domain: NSFileProviderDomain? = nil, @@ -337,12 +331,13 @@ extension Enumerator { deletedMetadatas: [ItemMetadata]?, readError: NKError? ) { + let ncAccount = remoteInterface.account let ncKitAccount = ncAccount.ncKitAccount Self.logger.debug( """ Starting to read serverUrl: \(serverUrl, privacy: .public) - for user: \(ncAccount.ncKitAccount, privacy: .public) + for user: \(ncKitAccount, privacy: .public) at depth \(depth.rawValue, privacy: .public). username: \(ncAccount.username, privacy: .public), password is empty: \(ncAccount.password == "" ? "EMPTY" : "NOT EMPTY"), diff --git a/Sources/NextcloudFileProviderKit/Enumeration/Enumerator.swift b/Sources/NextcloudFileProviderKit/Enumeration/Enumerator.swift index 79ed8aa..c012699 100644 --- a/Sources/NextcloudFileProviderKit/Enumeration/Enumerator.swift +++ b/Sources/NextcloudFileProviderKit/Enumeration/Enumerator.swift @@ -153,8 +153,7 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { Task { let (metadatas, _, _, _, readError) = await Self.readServerUrl( - serverUrl, - ncAccount: ncAccount, + serverUrl, remoteInterface: remoteInterface, dbManager: dbManager ) @@ -316,7 +315,6 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { _, newMetadatas, updatedMetadatas, deletedMetadatas, readError ) = await Self.readServerUrl( serverUrl, - ncAccount: ncAccount, remoteInterface: remoteInterface, dbManager: dbManager, stopAtMatchingEtags: true diff --git a/Sources/NextcloudFileProviderKit/Item/Item+Create.swift b/Sources/NextcloudFileProviderKit/Item/Item+Create.swift index b96d9ad..7066e7f 100644 --- a/Sources/NextcloudFileProviderKit/Item/Item+Create.swift +++ b/Sources/NextcloudFileProviderKit/Item/Item+Create.swift @@ -337,10 +337,7 @@ extension Item { // After everything, check into what the final state is of each folder now Self.logger.debug("Reading bpi folder at: \(remoteDirectoryPath, privacy: .public)") let (_, _, _, _, readError) = await Enumerator.readServerUrl( - remoteDirectoryPath, - ncAccount: ncAccount, - remoteInterface: remoteInterface, - dbManager: dbManager + remoteDirectoryPath, remoteInterface: remoteInterface, dbManager: dbManager ) if let readError, readError != .success { @@ -493,7 +490,6 @@ extension Item { ) let (metadatas, _, _, _, readError) = await Enumerator.readServerUrl( newServerUrlFileName, - ncAccount: ncAccount, remoteInterface: remoteInterface, dbManager: dbManager, domain: domain, diff --git a/Sources/NextcloudFileProviderKit/Item/Item+Fetch.swift b/Sources/NextcloudFileProviderKit/Item/Item+Fetch.swift index 5cfab21..32fcdb4 100644 --- a/Sources/NextcloudFileProviderKit/Item/Item+Fetch.swift +++ b/Sources/NextcloudFileProviderKit/Item/Item+Fetch.swift @@ -28,10 +28,7 @@ public extension Item { while !remoteDirectoryPaths.isEmpty { let remoteDirectoryPath = remoteDirectoryPaths.removeFirst() let (metadatas, _, _, _, readError) = await Enumerator.readServerUrl( - remoteDirectoryPath, - ncAccount: remoteInterface.account, - remoteInterface: remoteInterface, - dbManager: dbManager + remoteDirectoryPath, remoteInterface: remoteInterface, dbManager: dbManager ) if let readError, readError != .success { diff --git a/Sources/NextcloudFileProviderKit/Item/Item+Modify.swift b/Sources/NextcloudFileProviderKit/Item/Item+Modify.swift index 5b3d444..c736761 100644 --- a/Sources/NextcloudFileProviderKit/Item/Item+Modify.swift +++ b/Sources/NextcloudFileProviderKit/Item/Item+Modify.swift @@ -254,10 +254,7 @@ public extension Item { while !directoriesToRead.isEmpty { let remoteDirectoryPath = directoriesToRead.removeFirst() let (metadatas, _, _, _, readError) = await Enumerator.readServerUrl( - remoteDirectoryPath, - ncAccount: ncAccount, - remoteInterface: remoteInterface, - dbManager: dbManager + remoteDirectoryPath, remoteInterface: remoteInterface, dbManager: dbManager ) // Important note -- the enumerator will import found items' metadata into the database. // This is important for when we want to start deleting stale items and want to avoid trying @@ -457,10 +454,7 @@ public extension Item { for remoteDirectoryPath in remoteDirectoriesPaths { // After everything, check into what the final state is of each folder now let (_, _, _, _, readError) = await Enumerator.readServerUrl( - remoteDirectoryPath, - ncAccount: ncAccount, - remoteInterface: remoteInterface, - dbManager: dbManager + remoteDirectoryPath, remoteInterface: remoteInterface, dbManager: dbManager ) if let readError, readError != .success { From 9284c93806c3457b07b3e07365c7efd37d48f989 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 26 Jul 2024 20:52:29 +0800 Subject: [PATCH 2/6] Remove use of ncaccount entirely in enumerator --- .../Enumeration/Enumerator.swift | 85 ++++++++++++++----- .../EnumeratorTests.swift | 11 --- 2 files changed, 63 insertions(+), 33 deletions(-) diff --git a/Sources/NextcloudFileProviderKit/Enumeration/Enumerator.swift b/Sources/NextcloudFileProviderKit/Enumeration/Enumerator.swift index c012699..4fdc677 100644 --- a/Sources/NextcloudFileProviderKit/Enumeration/Enumerator.swift +++ b/Sources/NextcloudFileProviderKit/Enumeration/Enumerator.swift @@ -29,8 +29,8 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { private let anchor = NSFileProviderSyncAnchor(Date().description.data(using: .utf8)!) private static let maxItemsPerFileProviderPage = 100 static let logger = Logger(subsystem: Logger.subsystem, category: "enumerator") - let ncAccount: Account let remoteInterface: RemoteInterface + let ncKitAccount: String let fastEnumeration: Bool var serverUrl: String = "" var isInvalidated = false @@ -42,7 +42,6 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { public init( enumeratedItemIdentifier: NSFileProviderItemIdentifier, - ncAccount: Account, remoteInterface: RemoteInterface, dbManager: FilesDatabaseManager = .shared, domain: NSFileProviderDomain? = nil, @@ -50,8 +49,8 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { listener: EnumerationListener? = nil ) { self.enumeratedItemIdentifier = enumeratedItemIdentifier - self.ncAccount = ncAccount self.remoteInterface = remoteInterface + self.ncKitAccount = remoteInterface.account.ncKitAccount self.dbManager = dbManager self.domain = domain self.fastEnumeration = fastEnumeration @@ -61,7 +60,7 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { Self.logger.debug( "Providing enumerator for a system defined container: \(enumeratedItemIdentifier.rawValue, privacy: .public)" ) - serverUrl = ncAccount.davFilesUrl + serverUrl = remoteInterface.account.davFilesUrl } else { Self.logger.debug( "Providing enumerator for item with identifier: \(enumeratedItemIdentifier.rawValue, privacy: .public)" @@ -80,7 +79,10 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { } Self.logger.info( - "Set up enumerator for user: \(self.ncAccount.ncKitAccount, privacy: .public) with serverUrl: \(self.serverUrl, privacy: .public)" + """ + Set up enumerator for user: \(self.ncKitAccount, privacy: .public) + with serverUrl: \(self.serverUrl, privacy: .public) + """ ) super.init() } @@ -101,7 +103,11 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { listener?.enumerationActionStarted(actionId: actionId) Self.logger.debug( - "Received enumerate items request for enumerator with user: \(self.ncAccount.ncKitAccount, privacy: .public) with serverUrl: \(self.serverUrl, privacy: .public)" + """ + Received enumerate items request for enumerator with user: + \(self.ncKitAccount, privacy: .public) + with serverUrl: \(self.serverUrl, privacy: .public) + """ ) /* - inspect the page to determine whether this is an initial or a follow-up request (TODO) @@ -118,7 +124,10 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { if enumeratedItemIdentifier == .trashContainer { Self.logger.debug( - "Enumerating trash set for user: \(self.ncAccount.ncKitAccount, privacy: .public) with serverUrl: \(self.serverUrl, privacy: .public)" + """ + Enumerating trash set for user: \(self.ncKitAccount, privacy: .public) + with serverUrl: \(self.serverUrl, privacy: .public) + """ ) // TODO! @@ -148,7 +157,10 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { || page == NSFileProviderPage.initialPageSortedByName as NSFileProviderPage { Self.logger.debug( - "Enumerating initial page for user: \(self.ncAccount.ncKitAccount, privacy: .public) with serverUrl: \(self.serverUrl, privacy: .public)" + """ + Enumerating initial page for user: \(self.ncKitAccount, privacy: .public) + with serverUrl: \(self.serverUrl, privacy: .public) + """ ) Task { @@ -160,7 +172,11 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { guard readError == nil else { Self.logger.error( - "Finishing enumeration for user: \(self.ncAccount.ncKitAccount, privacy: .public) with serverUrl: \(self.serverUrl, privacy: .public) with error \(readError!.errorDescription, privacy: .public)" + """ + "Finishing enumeration for user: \(self.ncKitAccount, privacy: .public) + with serverUrl: \(self.serverUrl, privacy: .public) + with error \(readError!.errorDescription, privacy: .public) + """ ) // TODO: Refactor for conciseness @@ -173,7 +189,11 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { guard let metadatas else { Self.logger.error( - "Finishing enumeration for user: \(self.ncAccount.ncKitAccount, privacy: .public) with serverUrl: \(self.serverUrl, privacy: .public) with invalid metadatas." + """ + Finishing enumeration for user: \(self.ncKitAccount, privacy: .public) + with serverUrl: \(self.serverUrl, privacy: .public) + with invalid metadatas. + """ ) listener?.enumerationActionFailed( actionId: actionId, error: NSFileProviderError(.cannotSynchronize) @@ -183,7 +203,11 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { } Self.logger.info( - "Finished reading serverUrl: \(self.serverUrl, privacy: .public) for user: \(self.ncAccount.ncKitAccount, privacy: .public). Processed \(metadatas.count) metadatas" + """ + Finished reading serverUrl: \(self.serverUrl, privacy: .public) + for user: \(self.ncKitAccount, privacy: .public). + Processed \(metadatas.count) metadatas + """ ) Self.completeEnumerationObserver( @@ -201,7 +225,11 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { let numPage = Int(String(data: page.rawValue, encoding: .utf8)!)! Self.logger.debug( - "Enumerating page \(numPage, privacy: .public) for user: \(self.ncAccount.ncKitAccount, privacy: .public) with serverUrl: \(self.serverUrl, privacy: .public)" + """ + Enumerating page \(numPage, privacy: .public) + for user: \(self.ncKitAccount, privacy: .public) + with serverUrl: \(self.serverUrl, privacy: .public) + """ ) // TODO: Handle paging properly // Self.completeObserver(observer, ncKit: ncKit, numPage: numPage, itemMetadatas: nil) @@ -216,7 +244,11 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { listener?.enumerationActionStarted(actionId: actionId) Self.logger.debug( - "Received enumerate changes request for enumerator for user: \(self.ncAccount.ncKitAccount, privacy: .public) with serverUrl: \(self.serverUrl, privacy: .public)" + """ + Received enumerate changes request for enumerator for user: + \(self.ncKitAccount, privacy: .public) + with serverUrl: \(self.serverUrl, privacy: .public) + """ ) /* - query the server for updates since the passed-in sync anchor (TODO) @@ -230,7 +262,7 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { if enumeratedItemIdentifier == .workingSet { Self.logger.debug( - "Enumerating changes in working set for user: \(self.ncAccount.ncKitAccount, privacy: .public)" + "Enumerating changes in working set for: \(self.ncKitAccount, privacy: .public)" ) // Unlike when enumerating items we can't progressively enumerate items as we need to wait to resolve which items are truly deleted and which @@ -239,7 +271,6 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { let ( _, newMetadatas, updatedMetadatas, deletedMetadatas, error ) = await fullRecursiveScan( - ncAccount: ncAccount, remoteInterface: remoteInterface, dbManager: dbManager, scanChangesOnly: true @@ -249,7 +280,7 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { Self.logger.info( """ Enumerator invalidated during working set change scan. - For user: \(self.ncAccount.ncKitAccount, privacy: .public) + For user: \(self.ncKitAccount, privacy: .public) """ ) listener?.enumerationActionFailed(actionId: actionId, error: NSFileProviderError(.cannotSynchronize)) @@ -261,7 +292,7 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { Self.logger.info( """ Finished recursive change enumeration of working set for user: - \(self.ncAccount.ncKitAccount, privacy: .public) + \(self.ncKitAccount, privacy: .public) with error: \(error!.errorDescription, privacy: .public) """ ) @@ -276,7 +307,7 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { Self.logger.info( """ Finished recursive change enumeration of working set for user: - \(self.ncAccount.ncKitAccount, privacy: .public). Enumerating items. + \(self.ncKitAccount, privacy: .public). Enumerating items. """ ) @@ -294,7 +325,7 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { return } else if enumeratedItemIdentifier == .trashContainer { Self.logger.debug( - "Enumerating changes in trash set for user: \(self.ncAccount.ncKitAccount, privacy: .public)" + "Enumerating changes in trash set for user: \(self.ncKitAccount, privacy: .public)" ) // TODO! @@ -304,7 +335,10 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { } Self.logger.info( - "Enumerating changes for user: \(self.ncAccount.ncKitAccount, privacy: .public) with serverUrl: \(self.serverUrl, privacy: .public)" + """ + Enumerating changes for user: \(self.ncKitAccount, privacy: .public) + with serverUrl: \(self.serverUrl, privacy: .public) + """ ) // No matter what happens here we finish enumeration in some way, either from the error @@ -328,7 +362,11 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { guard readError == nil else { Self.logger.error( - "Finishing enumeration of changes for user: \(self.ncAccount.ncKitAccount, privacy: .public) with serverUrl: \(self.serverUrl, privacy: .public) with error: \(readError!.errorDescription, privacy: .public)" + """ + Finishing enumeration of changes for: \(self.ncKitAccount, privacy: .public) + with serverUrl: \(self.serverUrl, privacy: .public) + with error: \(readError!.errorDescription, privacy: .public) + """ ) let error = readError!.fileProviderError ?? NSFileProviderError(.cannotSynchronize) @@ -388,7 +426,10 @@ public class Enumerator: NSObject, NSFileProviderEnumerator { } Self.logger.info( - "Finished reading serverUrl: \(self.serverUrl, privacy: .public) for user: \(self.ncAccount.ncKitAccount, privacy: .public)" + """ + Finished reading serverUrl: \(self.serverUrl, privacy: .public) + for user: \(self.ncKitAccount, privacy: .public) + """ ) Self.completeChangesObserver( diff --git a/Tests/NextcloudFileProviderKitTests/EnumeratorTests.swift b/Tests/NextcloudFileProviderKitTests/EnumeratorTests.swift index ec272fa..3aa2b88 100644 --- a/Tests/NextcloudFileProviderKitTests/EnumeratorTests.swift +++ b/Tests/NextcloudFileProviderKitTests/EnumeratorTests.swift @@ -93,7 +93,6 @@ final class EnumeratorTests: XCTestCase { let enumerator = Enumerator( enumeratedItemIdentifier: .rootContainer, - ncAccount: Self.account, remoteInterface: remoteInterface, dbManager: Self.dbManager ) @@ -148,7 +147,6 @@ final class EnumeratorTests: XCTestCase { let enumerator = Enumerator( enumeratedItemIdentifier: .workingSet, - ncAccount: Self.account, remoteInterface: remoteInterface, dbManager: Self.dbManager ) @@ -178,7 +176,6 @@ final class EnumeratorTests: XCTestCase { let enumerator = Enumerator( enumeratedItemIdentifier: .workingSet, - ncAccount: Self.account, remoteInterface: remoteInterface, dbManager: Self.dbManager ) @@ -222,7 +219,6 @@ final class EnumeratorTests: XCTestCase { let enumerator = Enumerator( enumeratedItemIdentifier: .workingSet, - ncAccount: Self.account, remoteInterface: remoteInterface, dbManager: Self.dbManager, fastEnumeration: false @@ -269,7 +265,6 @@ final class EnumeratorTests: XCTestCase { let enumerator = Enumerator( enumeratedItemIdentifier: .init(remoteFolder.identifier), - ncAccount: Self.account, remoteInterface: remoteInterface, dbManager: Self.dbManager ) @@ -343,7 +338,6 @@ final class EnumeratorTests: XCTestCase { let enumerator = Enumerator( enumeratedItemIdentifier: .init(remoteItemA.identifier), - ncAccount: Self.account, remoteInterface: remoteInterface, dbManager: Self.dbManager ) @@ -418,7 +412,6 @@ final class EnumeratorTests: XCTestCase { let enumerator = Enumerator( enumeratedItemIdentifier: .init(remoteFolder.identifier), - ncAccount: Self.account, remoteInterface: remoteInterface, dbManager: Self.dbManager ) @@ -555,7 +548,6 @@ final class EnumeratorTests: XCTestCase { let enumerator = Enumerator( enumeratedItemIdentifier: .rootContainer, - ncAccount: Self.account, remoteInterface: remoteInterface, dbManager: Self.dbManager ) @@ -648,7 +640,6 @@ final class EnumeratorTests: XCTestCase { let enumerator = Enumerator( enumeratedItemIdentifier: .init(remoteFolder.identifier), - ncAccount: Self.account, remoteInterface: remoteInterface, dbManager: Self.dbManager ) @@ -722,7 +713,6 @@ final class EnumeratorTests: XCTestCase { let enumerator = Enumerator( enumeratedItemIdentifier: .rootContainer, - ncAccount: Self.account, remoteInterface: remoteInterface, dbManager: Self.dbManager ) @@ -759,7 +749,6 @@ final class EnumeratorTests: XCTestCase { let enumerator = Enumerator( enumeratedItemIdentifier: .workingSet, - ncAccount: Self.account, remoteInterface: remoteInterface, dbManager: Self.dbManager, listener: listener From 87356f28f2084a88161cf5b43949d94dab979fff Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 26 Jul 2024 21:37:56 +0800 Subject: [PATCH 3/6] Remove unneeded use of ncaccount in create bundle or package procedure --- Sources/NextcloudFileProviderKit/Item/Item+Create.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Sources/NextcloudFileProviderKit/Item/Item+Create.swift b/Sources/NextcloudFileProviderKit/Item/Item+Create.swift index 7066e7f..da36ec3 100644 --- a/Sources/NextcloudFileProviderKit/Item/Item+Create.swift +++ b/Sources/NextcloudFileProviderKit/Item/Item+Create.swift @@ -199,7 +199,6 @@ extension Item { remotePath: String, domain: NSFileProviderDomain? = nil, remoteInterface: RemoteInterface, - ncAccount: Account, progress: Progress, dbManager: FilesDatabaseManager ) async throws -> Item? { @@ -352,14 +351,14 @@ extension Item { } guard let bundleRootMetadata = dbManager.itemMetadata( - account: ncAccount.ncKitAccount, locatedAtRemoteUrl: remotePath + account: remoteInterface.account.ncKitAccount, locatedAtRemoteUrl: remotePath ) else { Self.logger.error( """ Could not find directory metadata for bundle or package at: \(remotePath, privacy: .public) of account: - \(ncAccount.ncKitAccount, privacy: .public) + \(remoteInterface.account.ncKitAccount, privacy: .public) with contents located at: \(contentsPath, privacy: .public) """ @@ -559,7 +558,6 @@ extension Item { remotePath: newServerUrlFileName, domain: domain, remoteInterface: remoteInterface, - ncAccount: ncAccount, progress: progress, dbManager: dbManager ), nil) From 465f45670a8c672a560f5df654b4f77b4ac6acd5 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 26 Jul 2024 21:40:10 +0800 Subject: [PATCH 4/6] Remove unneeded use of ncaccount in item create --- Sources/NextcloudFileProviderKit/Item/Item+Create.swift | 3 +-- Tests/NextcloudFileProviderKitTests/ItemCreateTests.swift | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Sources/NextcloudFileProviderKit/Item/Item+Create.swift b/Sources/NextcloudFileProviderKit/Item/Item+Create.swift index da36ec3..5d98d1d 100644 --- a/Sources/NextcloudFileProviderKit/Item/Item+Create.swift +++ b/Sources/NextcloudFileProviderKit/Item/Item+Create.swift @@ -383,7 +383,6 @@ extension Item { request: NSFileProviderRequest = NSFileProviderRequest(), domain: NSFileProviderDomain? = nil, remoteInterface: RemoteInterface, - ncAccount: Account, progress: Progress, dbManager: FilesDatabaseManager = .shared ) async -> (Item?, Error?) { @@ -412,7 +411,7 @@ extension Item { // TODO: Deduplicate if parentItemIdentifier == .rootContainer { - parentItemRemotePath = ncAccount.davFilesUrl + parentItemRemotePath = remoteInterface.account.davFilesUrl } else { guard let parentItemMetadata = dbManager.directoryMetadata( ocId: parentItemIdentifier.rawValue diff --git a/Tests/NextcloudFileProviderKitTests/ItemCreateTests.swift b/Tests/NextcloudFileProviderKitTests/ItemCreateTests.swift index 3b6c716..ec746b4 100644 --- a/Tests/NextcloudFileProviderKitTests/ItemCreateTests.swift +++ b/Tests/NextcloudFileProviderKitTests/ItemCreateTests.swift @@ -57,7 +57,6 @@ final class ItemCreateTests: XCTestCase { basedOn: folderItemTemplate, contents: nil, remoteInterface: remoteInterface, - ncAccount: Self.account, progress: Progress(), dbManager: Self.dbManager ) @@ -106,7 +105,6 @@ final class ItemCreateTests: XCTestCase { basedOn: fileItemTemplate, contents: tempUrl, remoteInterface: remoteInterface, - ncAccount: Self.account, progress: Progress(), dbManager: Self.dbManager ) @@ -154,7 +152,6 @@ final class ItemCreateTests: XCTestCase { basedOn: folderItemTemplate, contents: nil, remoteInterface: remoteInterface, - ncAccount: Self.account, progress: Progress(), dbManager: Self.dbManager ) @@ -184,7 +181,6 @@ final class ItemCreateTests: XCTestCase { basedOn: fileItemTemplate, contents: tempUrl, remoteInterface: remoteInterface, - ncAccount: Self.account, progress: Progress(), dbManager: Self.dbManager ) @@ -300,7 +296,6 @@ final class ItemCreateTests: XCTestCase { basedOn: bundleItemTemplate, contents: tempUrl, remoteInterface: remoteInterface, - ncAccount: Self.account, progress: Progress(), dbManager: Self.dbManager ) From 5a1ca729c5e1e8393bae84d61f193da0816d3fcf Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 26 Jul 2024 21:45:42 +0800 Subject: [PATCH 5/6] Remove unused ncaccount in modify bundle contents --- Sources/NextcloudFileProviderKit/Item/Item+Modify.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sources/NextcloudFileProviderKit/Item/Item+Modify.swift b/Sources/NextcloudFileProviderKit/Item/Item+Modify.swift index c736761..a526050 100644 --- a/Sources/NextcloudFileProviderKit/Item/Item+Modify.swift +++ b/Sources/NextcloudFileProviderKit/Item/Item+Modify.swift @@ -212,7 +212,6 @@ public extension Item { private func modifyBundleOrPackageContents( contents newContents: URL?, remotePath: String, - ncAccount: Account, domain: NSFileProviderDomain?, progress: Progress, dbManager: FilesDatabaseManager @@ -644,7 +643,6 @@ public extension Item { contentModifiedItem = try await modifiedItem.modifyBundleOrPackageContents( contents: newContents, remotePath: newServerUrlFileName, - ncAccount: ncAccount, domain: domain, progress: progress, dbManager: dbManager From 172302ee79f504bfb0ae5298a8762f1cc673b0ef Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 26 Jul 2024 21:51:29 +0800 Subject: [PATCH 6/6] Remove unnecessary use of ncaccount in item modify --- Sources/NextcloudFileProviderKit/Item/Item+Modify.swift | 3 +-- Tests/NextcloudFileProviderKitTests/ItemModifyTests.swift | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Sources/NextcloudFileProviderKit/Item/Item+Modify.swift b/Sources/NextcloudFileProviderKit/Item/Item+Modify.swift index a526050..232559e 100644 --- a/Sources/NextcloudFileProviderKit/Item/Item+Modify.swift +++ b/Sources/NextcloudFileProviderKit/Item/Item+Modify.swift @@ -495,7 +495,6 @@ public extension Item { contents newContents: URL?, options: NSFileProviderModifyItemOptions = [], request: NSFileProviderRequest = NSFileProviderRequest(), - ncAccount: Account, domain: NSFileProviderDomain? = nil, progress: Progress = .init(), dbManager: FilesDatabaseManager = .shared @@ -530,7 +529,7 @@ public extension Item { // remote changes and then, upon user interaction, will try to modify the item. // That is, if the parent item has changed at all (it might not have) if parentItemIdentifier == .rootContainer { - parentItemServerUrl = ncAccount.davFilesUrl + parentItemServerUrl = remoteInterface.account.davFilesUrl } else { guard let parentItemMetadata = dbManager.directoryMetadata( ocId: parentItemIdentifier.rawValue diff --git a/Tests/NextcloudFileProviderKitTests/ItemModifyTests.swift b/Tests/NextcloudFileProviderKitTests/ItemModifyTests.swift index ff4f3f7..64316a7 100644 --- a/Tests/NextcloudFileProviderKitTests/ItemModifyTests.swift +++ b/Tests/NextcloudFileProviderKitTests/ItemModifyTests.swift @@ -123,7 +123,6 @@ final class ItemModifyTests: XCTestCase { itemTarget: targetItem, changedFields: [.filename, .contents, .parentItemIdentifier, .contentModificationDate], contents: newContentsUrl, - ncAccount: Self.account, dbManager: Self.dbManager ) XCTAssertNil(error) @@ -587,7 +586,6 @@ final class ItemModifyTests: XCTestCase { itemTarget: targetItem, changedFields: [.filename, .contents, .parentItemIdentifier, .contentModificationDate], contents: tempUrl, - ncAccount: Self.account, dbManager: Self.dbManager ) XCTAssertNil(error)