Add ability to set handlers from AlamoFire request on Progress extension

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-03-15 12:36:48 +01:00
parent d4d5c8f8da
commit 607d72615d
No known key found for this signature in database
GPG key ID: C839200C384636B0

View file

@ -13,8 +13,15 @@
*/
import Foundation
import Alamofire
extension Progress {
func setHandlersFromAfRequest(_ request: Request) {
self.cancellationHandler = { request.cancel() }
self.pausingHandler = { request.suspend() }
self.resumingHandler = { request.resume() }
}
func copyCurrentStateToProgress(_ otherProgress: Progress, includeHandlers: Bool = false) {
if includeHandlers {
otherProgress.cancellationHandler = self.cancellationHandler