Skip to content

Commit f04fcbd

Browse files
Add check to only report progress if content length is known (Adyen#20)
1 parent 4a40045 commit f04fcbd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

AdyenNetworking/APIClient/APIClient.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,10 @@ extension APIClient: AsyncAPIClientProtocol {
351351

352352
for try await byte in asyncBytes {
353353
data.append(byte)
354-
let progress = Double(data.count) / Double(contentLength)
355-
request.onProgressUpdate?(progress)
354+
if contentLength > 0 {
355+
let progress = Double(data.count) / Double(contentLength)
356+
request.onProgressUpdate?(progress)
357+
}
356358
}
357359

358360
let destinationUrl = try generateFileDestination(

0 commit comments

Comments
 (0)