Move `downloadFileEx` out of `downloadFile` (solution, proposed by @Yardanico). Tested manually.
This commit is contained in:
parent
dfe6797023
commit
fdf4f74cd1
1 changed files with 22 additions and 22 deletions
|
|
@ -1221,9 +1221,7 @@ 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,
|
||||
proc downloadFileEx(client: AsyncHttpClient,
|
||||
url: Uri | string, filename: string): Future[void] {.async.} =
|
||||
## Downloads ``url`` and saves it to ``filename``.
|
||||
client.getBody = false
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue