Skip to content

Commit 1223f5e

Browse files
authored
Fix FileDownloadDelegate example code in README.md (swift-server#305)
The progress API of `FileDownloadDelegate` changed at the last minute, but the example in `README.md` wasn't updated accordingly.
1 parent 49a0d30 commit 1223f5e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,18 @@ let request = try HTTPClient.Request(
179179
)
180180

181181
let delegate = try FileDownloadDelegate(path: "/tmp/latest-build.yml", reportProgress: {
182-
if let totalSize = $0 {
183-
print("Total bytes count: \(totalSize)")
182+
if let totalBytes = $0.totalBytes {
183+
print("Total bytes count: \(totalBytes)")
184184
}
185-
print("Downloaded \($1) bytes so far")
185+
print("Downloaded \($0.receivedBytes) bytes so far")
186186
})
187187

188188
client.execute(request: request, delegate: delegate).futureResult
189-
.whenSuccess { finalTotalBytes, downloadedBytes in
190-
if let totalSize = $0 {
191-
print("Final total bytes count: \(totalSize)")
189+
.whenSuccess { progress in
190+
if let totalBytes = progress.totalBytes {
191+
print("Final total bytes count: \(totalBytes)")
192192
}
193-
print("Downloaded finished with \($1) bytes downloaded")
193+
print("Downloaded finished with \(progress.receivedBytes) bytes downloaded")
194194
}
195195
```
196196

0 commit comments

Comments
 (0)