Skip to content

Commit 1f27a2f

Browse files
liyang1009Araq
authored andcommitted
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
1 parent ee1563e commit 1f27a2f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/pure/asyncftpclient.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,13 @@ proc doUpload(ftp: AsyncFtpClient, file: File,
351351
assert ftp.dsockConnected
352352

353353
let total = file.getFileSize()
354-
var data = newStringOfCap(4000)
354+
var data = newString(4000)
355355
var progress = 0
356356
var progressInSecond = 0
357357
var countdownFut = sleepAsync(1000)
358358
var sendFut: Future[void] = nil
359359
while ftp.dsockConnected:
360-
if sendFut == nil or sendFut.finished:
361-
progress.inc(data.len)
362-
progressInSecond.inc(data.len)
360+
if sendFut == nil or sendFut.finished:
363361
# TODO: Async file reading.
364362
let len = file.readBuffer(addr(data[0]), 4000)
365363
setLen(data, len)
@@ -370,6 +368,8 @@ proc doUpload(ftp: AsyncFtpClient, file: File,
370368

371369
assertReply(await(ftp.expectReply()), "226")
372370
else:
371+
progress.inc(len)
372+
progressInSecond.inc(len)
373373
sendFut = ftp.dsock.send(data)
374374

375375
if countdownFut.finished:

0 commit comments

Comments
 (0)