From b2ae60f0a91adac5eedd190cbfe4bd6b3df327e5 Mon Sep 17 00:00:00 2001 From: "Thomas A. Hirsch" Date: Wed, 21 Oct 2020 18:06:52 +0100 Subject: [PATCH] $progressCallback should be called after a specific amount of data has been received and not, if its just requested, as the requested packets might be more as the available and received data. --- phpseclib/Net/SFTP.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 525f98ac..a94215b8 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -2309,9 +2309,6 @@ class Net_SFTP extends Net_SSH2 } $packet = null; $read+= $packet_size; - if (is_callable($progressCallback)) { - call_user_func($progressCallback, $read); - } $i++; } @@ -2341,6 +2338,9 @@ class Net_SFTP extends Net_SSH2 } else { fputs($fp, $temp); } + if (is_callable($progressCallback)) { + call_user_func($progressCallback, $offset); + } $temp = null; break; case NET_SFTP_STATUS: