Closed Jakuje closed 3 months ago
Congratulations! One of the builds has completed. :champagne:
You can install the built RPMs by following these steps:
sudo yum install -y dnf-plugins-core
on RHEL 8sudo dnf install -y dnf-plugins-core
on Fedoradnf copr enable packit/ansible-pylibssh-621
Please note that the RPMs should be used only in a testing environment.
@Jakuje FYI the linting failures block this PR
The suggestions accepted, the linting should pass now.
@Jakuje hey, so I added a few improvements on top and posted a few more comments inline. I've now stopped pushing to the PR branch so feel free to clean it up/rebase/make more changes.
This needs conflict resolution now.
Resolved the conflict and dropped the check for too large replies.
Looks like one of the CI jobs got stuck with https://github.com/ansible/pylibssh/issues/557 so I restarted it: https://github.com/ansible/pylibssh/actions/runs/9699687288/job/26769948869?pr=621#step:15:152.
@Jakuje this has been released as a part of v1.2.2: https://github.com/ansible/pylibssh/releases/tag/v1.2.2 / https://github.com/ansible/pylibssh/discussions/626 / https://pypi.org/project/ansible-pylibssh/1.2.2/.
Enjoy! 🎉
SUMMARY
The current SCP code does not handle large reads. Instead just allocates the large buffer fills up to 64k bytes and then writes the whole to the file (most likely the rest filled with junk).
The libssh returns the number of read bytes from
ssh_scp_read()
and for practical reasons does not allocate the whole file in memory. The reads are capped to 64k B.This PR fixes the read by both not allocating the entire file size in memory and reading it by chunks (that much max libssh chunk atm) and writing that to the local file.
ISSUE TYPE
ADDITIONAL INFORMATION
The attached test case is failing without the change, with errors like this:
(lines do not match)
Additionally, there is one more test case, that I suspected will be problematic, but it turned out it works just ok, so leaving for the coverage.