From 590cc057d31a43e06e4c9d585117a14fd99c9bdc Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Wed, 11 Dec 2024 14:30:25 +0100 Subject: [PATCH 1/4] cod Signed-off-by: Marino Faggiana --- File Provider Extension/FileProviderEnumerator.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/File Provider Extension/FileProviderEnumerator.swift b/File Provider Extension/FileProviderEnumerator.swift index 5af23b3648..0c73983ab0 100644 --- a/File Provider Extension/FileProviderEnumerator.swift +++ b/File Provider Extension/FileProviderEnumerator.swift @@ -33,7 +33,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator { let database = NCManageDatabase.shared var anchor: UInt64 = 0 // X-NC-PAGINATE - var recordsPerPage: Int = 5 + var recordsPerPage: Int = 50 var paginateToken: String? var paginatedTotal: Int? @@ -168,7 +168,10 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator { paginateCount += 1 } var useFirstAsMetadataFolder: Bool = false - let offset = pageNumber * recordsPerPage + var offset = pageNumber * recordsPerPage + if pageNumber > 0 { + offset += 1 + } let options = NKRequestOptions(paginate: true, paginateToken: self.paginateToken, paginateOffset: offset, From ec836e30cc1b46e8f8fb1a8abfdcdf975f4db53e Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Wed, 11 Dec 2024 14:51:08 +0100 Subject: [PATCH 2/4] pag 100 Signed-off-by: Marino Faggiana --- File Provider Extension/FileProviderEnumerator.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/File Provider Extension/FileProviderEnumerator.swift b/File Provider Extension/FileProviderEnumerator.swift index 0c73983ab0..300da33970 100644 --- a/File Provider Extension/FileProviderEnumerator.swift +++ b/File Provider Extension/FileProviderEnumerator.swift @@ -33,9 +33,9 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator { let database = NCManageDatabase.shared var anchor: UInt64 = 0 // X-NC-PAGINATE - var recordsPerPage: Int = 50 + var recordsPerPage: Int = 100 var paginateToken: String? - var paginatedTotal: Int? + var paginatedTotal: Int = 0 init(enumeratedItemIdentifier: NSFileProviderItemIdentifier) { self.enumeratedItemIdentifier = enumeratedItemIdentifier @@ -178,12 +178,14 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator { paginateCount: paginateCount, queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue) + print("PAGINATE OFFSET: \(offset) COUNT: \(paginateCount) TOTAL: \(self.paginatedTotal)") + NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", showHiddenFiles: NCKeychain().showHiddenFiles, account: fileProviderData.shared.session.account, options: options) { _, files, responseData, error in if let headers = responseData?.response?.allHeaderFields as? [String: String] { let normalizedHeaders = Dictionary(uniqueKeysWithValues: headers.map { ($0.key.lowercased(), $0.value) }) isPaginated = Bool(normalizedHeaders["x-nc-paginate"] ?? "false") ?? false self.paginateToken = normalizedHeaders["x-nc-paginate-token"] - self.paginatedTotal = Int(normalizedHeaders["x-nc-paginate-total"] ?? "0") + self.paginatedTotal = Int(normalizedHeaders["x-nc-paginate-total"] ?? "0") ?? 0 } if error == .success, let files { From 484a960b94cc9ae3ecff0f62bf1362f2ea4a41db Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Wed, 11 Dec 2024 15:01:34 +0100 Subject: [PATCH 3/4] cod Signed-off-by: Marino Faggiana --- File Provider Extension/FileProviderEnumerator.swift | 2 +- .../FileProviderExtension+Thumbnail.swift | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/File Provider Extension/FileProviderEnumerator.swift b/File Provider Extension/FileProviderEnumerator.swift index 300da33970..f9cdd88cde 100644 --- a/File Provider Extension/FileProviderEnumerator.swift +++ b/File Provider Extension/FileProviderEnumerator.swift @@ -162,12 +162,12 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator { } func fetchItemsForPage(serverUrl: String, pageNumber: Int, completion: @escaping (_ metadatas: [tableMetadata]?, _ isPaginated: Bool) -> Void) { + var useFirstAsMetadataFolder: Bool = false var isPaginated: Bool = false var paginateCount = recordsPerPage if pageNumber == 0 { paginateCount += 1 } - var useFirstAsMetadataFolder: Bool = false var offset = pageNumber * recordsPerPage if pageNumber > 0 { offset += 1 diff --git a/File Provider Extension/FileProviderExtension+Thumbnail.swift b/File Provider Extension/FileProviderExtension+Thumbnail.swift index 0cffbb8515..1ee9178345 100644 --- a/File Provider Extension/FileProviderExtension+Thumbnail.swift +++ b/File Provider Extension/FileProviderExtension+Thumbnail.swift @@ -32,9 +32,13 @@ extension FileProviderExtension { var counterProgress: Int64 = 0 for itemIdentifier in itemIdentifiers { - guard let metadata = providerUtility.getTableMetadataFromItemIdentifier(itemIdentifier), metadata.hasPreview else { + guard let metadata = providerUtility.getTableMetadataFromItemIdentifier(itemIdentifier), + metadata.hasPreview + else { counterProgress += 1 - if counterProgress == progress.totalUnitCount { completionHandler(nil) } + if counterProgress == progress.totalUnitCount { + completionHandler(nil) + } continue } @@ -55,6 +59,7 @@ extension FileProviderExtension { } } } + return progress } } From cb792338a219c082dc1ecf8a7e11f725eb75311f Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Wed, 11 Dec 2024 15:16:47 +0100 Subject: [PATCH 4/4] downloadPreview Signed-off-by: Marino Faggiana --- File Provider Extension/FileProviderExtension+Thumbnail.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/File Provider Extension/FileProviderExtension+Thumbnail.swift b/File Provider Extension/FileProviderExtension+Thumbnail.swift index 1ee9178345..e3d58c2e8b 100644 --- a/File Provider Extension/FileProviderExtension+Thumbnail.swift +++ b/File Provider Extension/FileProviderExtension+Thumbnail.swift @@ -43,8 +43,8 @@ extension FileProviderExtension { } NextcloudKit.shared.downloadPreview(fileId: metadata.fileId, - width: Int(size.width), - height: Int(size.height), + width: Int(NCGlobal.shared.size512.width), + height: Int(NCGlobal.shared.size512.height), etag: metadata.etag, account: metadata.account) { _ in } completion: { _, _, _, _, responseData, error in