mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 09:54:49 +00:00
asyncftpclient fixes
This commit is contained in:
@@ -131,12 +131,13 @@ type
|
||||
const multiLineLimit = 10000
|
||||
|
||||
proc expectReply(ftp: AsyncFtpClient): Future[TaintedString] {.async.} =
|
||||
result = await ftp.csock.recvLine()
|
||||
var line = await ftp.csock.recvLine()
|
||||
result = TaintedString(line)
|
||||
var count = 0
|
||||
while line.len > 3 and line[3] == '-':
|
||||
## Multi-line reply.
|
||||
let line = await ftp.csock.recvLine()
|
||||
result.add("\n" & line)
|
||||
line = await ftp.csock.recvLine()
|
||||
string(result).add("\n" & line)
|
||||
count.inc()
|
||||
if count >= multiLineLimit:
|
||||
raise newException(ReplyError, "Reached maximum multi-line reply count.")
|
||||
@@ -182,7 +183,7 @@ proc connect*(ftp: AsyncFtpClient) {.async.} =
|
||||
await ftp.csock.connect(ftp.address, ftp.port)
|
||||
|
||||
var reply = await ftp.expectReply()
|
||||
if reply.startsWith("120"):
|
||||
if string(reply).startsWith("120"):
|
||||
# 120 Service ready in nnn minutes.
|
||||
# We wait until we receive 220.
|
||||
reply = await ftp.expectReply()
|
||||
@@ -361,7 +362,7 @@ proc doUpload(ftp: AsyncFtpClient, file: File,
|
||||
var countdownFut = sleepAsync(1000)
|
||||
var sendFut: Future[void] = nil
|
||||
while ftp.dsockConnected:
|
||||
if sendFut == nil or sendFut.finished:
|
||||
if sendFut == nil or sendFut.finished:
|
||||
# TODO: Async file reading.
|
||||
let len = file.readBuffer(addr(data[0]), 4000)
|
||||
setLen(data, len)
|
||||
|
||||
Reference in New Issue
Block a user