Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the ftp store function read the local file bug #13108

Merged
merged 2 commits into from
Jan 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/pure/asyncftpclient.nim
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,13 @@ proc doUpload(ftp: AsyncFtpClient, file: File,
assert ftp.dsockConnected

let total = file.getFileSize()
var data = newStringOfCap(4000)
var data = newString(4000)
var progress = 0
var progressInSecond = 0
var countdownFut = sleepAsync(1000)
var sendFut: Future[void] = nil
while ftp.dsockConnected:
if sendFut == nil or sendFut.finished:
progress.inc(data.len)
progressInSecond.inc(data.len)
if sendFut == nil or sendFut.finished:
# TODO: Async file reading.
let len = file.readBuffer(addr(data[0]), 4000)
setLen(data, len)
Expand All @@ -370,6 +368,8 @@ proc doUpload(ftp: AsyncFtpClient, file: File,

assertReply(await(ftp.expectReply()), "226")
else:
progress.inc(len)
progressInSecond.inc(len)
sendFut = ftp.dsock.send(data)

if countdownFut.finished:
Expand Down