mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-01 02:42:05 +00:00
fix the ftp store function read the local file bug (#13108) [backport]
* Update asyncftpclient.nim When use newStringOfCap function not have assign memory for the string data,so if use this address the fault is rasise. * complelete the bugfix
This commit is contained in:
committed by
Andreas Rumpf
parent
ee1563ef33
commit
1f27a2f8ab
@@ -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)
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user