Skip to content

Commit b0eec5f

Browse files
committed
fix(chunk): Add option to not overwrite conflicting files at destination path for chunk assembly
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
1 parent e6089fa commit b0eec5f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎Sources/NextcloudKit/NextcloudKit+Upload.swift‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ public extension NextcloudKit {
190190
/// - account: Account identifier.
191191
/// - options: Request options (headers, timeout, etc.).
192192
/// - ifMatch: Optional ETag precondition applied **only** to the final assembly `MOVE` (not the chunk uploads). When set, the server rejects the assembly with `412 Precondition Failed` if the destination changed since this ETag, enabling optimistic-concurrency conflict detection for chunked uploads.
193+
/// - overwrite: Whether the final assembly may replace an existing destination. Defaults to true for existing callers.
193194
/// - chunkProgressHandler: Reports per-chunk preparation progress as `(totalChunks, currentIndex)`.
194195
/// - uploadStart: Called once when upload of chunks begins, with the final list of chunks.
195196
/// - uploadTaskHandler: Exposes the low-level `URLSessionTask` for each chunk upload.
@@ -213,6 +214,7 @@ public extension NextcloudKit {
213214
account: String,
214215
options: NKRequestOptions = NKRequestOptions(),
215216
ifMatch: String? = nil,
217+
overwrite: Bool = true,
216218
chunkProgressHandler: @escaping (_ total: Int, _ counter: Int) -> Void = { _, _ in },
217219
uploadStart: @escaping (_ filesChunk: [(fileName: String, size: Int64)]) -> Void = { _ in },
218220
uploadTaskHandler: @escaping (_ task: URLSessionTask) -> Void = { _ in },
@@ -428,7 +430,7 @@ public extension NextcloudKit {
428430

429431
let moveRes = await moveFileOrFolderAsync(serverUrlFileNameSource: serverUrlFileNameSource,
430432
serverUrlFileNameDestination: serverUrlFileName,
431-
overwrite: true,
433+
overwrite: overwrite,
432434
account: account,
433435
options: options)
434436

0 commit comments

Comments
 (0)