Move `downloadFileEx` out of `downloadFile` (solution, proposed by
@Yardanico).

Tested manually.
This commit is contained in:
Roman Inflianskas 2021-01-21 23:29:24 +00:00 • committed by GitHub
commit fdf4f74cd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1221,8 +1221,6 @@ proc downloadFile*(client: HttpClient, url: Uri | string, filename: string) =
if resp.code.is4xx or resp.code.is5xx:
raise newException(HttpRequestError, resp.status)
proc downloadFile*(client: AsyncHttpClient, url: Uri | string,
filename: string): Future[void] =
proc downloadFileEx(client: AsyncHttpClient,
url: Uri | string, filename: string): Future[void] {.async.} =
## Downloads ``url`` and saves it to ``filename``.
@ -1245,6 +1243,8 @@ proc downloadFile*(client: AsyncHttpClient, url: Uri | string,
if resp.code.is4xx or resp.code.is5xx:
raise newException(HttpRequestError, resp.status)
proc downloadFile*(client: AsyncHttpClient, url: Uri | string,
filename: string): Future[void] =
result = newFuture[void]("downloadFile")
try:
result = downloadFileEx(client, url, filename)