Skip to content

Commit 71b1082

Browse files
doc
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
1 parent 291c2ca commit 71b1082

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

Sources/NextcloudKit/NextcloudKit+Upload.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,27 @@ public extension NextcloudKit {
167167
}
168168
}
169169

170+
/// Actor responsible for holding and controlling the lifecycle of a single `UploadRequest`.
171+
///
172+
/// This actor serializes access to the currently active request and ensures safe
173+
/// cancellation or cleanup from any calling context. Only one request is stored
174+
/// at a time; setting a new one replaces the previous reference.
175+
///
176+
/// Typical usage:
177+
/// - `set(_:)` from the request handler when a new upload task starts.
178+
/// - `cancel()` from outside when the upload must be interrupted.
179+
/// - `clear()` after completion or failure to release strong references.
170180
actor ActorRequest {
171181
private var request: UploadRequest?
172182

173-
// Set/replace the active request (called from requestHandler)
174183
func set(_ req: UploadRequest?) {
175184
self.request = req
176185
}
177186

178-
// Cancel if present
179187
func cancel() {
180188
self.request?.cancel()
181189
}
182190

183-
// Clear to break strong references when done
184191
func clear() {
185192
self.request = nil
186193
}

0 commit comments

Comments
 (0)