// MARK: - Helper methods
- private static func completeEnumerationObserver(_ observer: NSFileProviderEnumerationObserver, ncKit: NextcloudKit, numPage: Int, itemMetadatas: [NextcloudItemMetadataTable], createLocalFileOrDirectory: Bool = true) {
+ private static func completeEnumerationObserver(_ observer: NSFileProviderEnumerationObserver, ncKit: NextcloudKit, numPage: Int, itemMetadatas: [NextcloudItemMetadataTable]) {
var items: [NSFileProviderItem] = []
continue
}
- if createLocalFileOrDirectory {
- createFileOrDirectoryLocally(metadata: itemMetadata)
- }
-
if let parentItemIdentifier = NextcloudFilesDatabaseManager.shared.parentItemIdentifierFromMetadata(itemMetadata) {
let item = FileProviderItem(metadata: itemMetadata, parentItemIdentifier: parentItemIdentifier, ncKit: ncKit)
Logger.enumeration.debug("Will enumerate item with ocId: \(itemMetadata.ocId) and name: \(itemMetadata.fileName, privacy: OSLogPrivacy.auto(mask: .hash))")
return folderPathUrl
}
-@discardableResult func localPathForNCDirectory(directoryMetadata: NextcloudDirectoryMetadataTable) throws -> URL {
- let ocId = directoryMetadata.ocId
- return try localPathForNCDirectory(ocId: ocId)
-}
-
-@discardableResult func localPathForNCDirectory(itemMetadata: NextcloudItemMetadataTable) throws -> URL {
- let ocId = itemMetadata.ocId
- return try localPathForNCDirectory(ocId: ocId)
-}
-
@discardableResult func localPathForNCFile(ocId: String, fileNameView: String) throws -> URL {
let fileFolderPathUrl = try localPathForNCDirectory(ocId: ocId)
let filePathUrl = fileFolderPathUrl.appendingPathComponent(fileNameView)
return filePathUrl
}
-
-@discardableResult func localPathForNCFile(itemMetadata: NextcloudItemMetadataTable) throws -> URL {
- let ocId = itemMetadata.ocId
- let fileNameView = itemMetadata.fileNameView
- return try localPathForNCFile(ocId: ocId, fileNameView: fileNameView)
-}
-
-func createFileOrDirectoryLocally(metadata: NextcloudItemMetadataTable) {
- do {
- if metadata.directory {
- try localPathForNCDirectory(ocId: metadata.ocId)
- } else {
- try localPathForNCFile(itemMetadata: metadata)
- }
- } catch let error {
- Logger.enumeration.error("Could not create NC file or directory locally, received error: \(error, privacy: .public)")
- }
-}