perf: ensure full write buffer for *File.ReadFrom

In `*File.ReadFrom`, ensure that the buffer is filled to capacity (`maxPacket`
length) before performing the write.

Prior to this change, the amount of data read into the buffer was dictated by
the `io.Reader`'s `Read` implementation, and write performance would suffer
when the Read would return less than maxPacket bytes of data. An example
source would be a `net/http` response `Body` from a TLS server, which
seems to cap each read to 16384 bytes -- half the default max packet size of
32768 bytes.
1 file changed
tree: 98ef9f163852bc459833bcd66fcaf83e07a67b5b
  1. .github/
  2. examples/
  3. internal/
  4. server_standalone/
  5. .gitignore
  6. allocator.go
  7. allocator_test.go
  8. attrs.go
  9. attrs_stubs.go
  10. attrs_test.go
  11. attrs_unix.go
  12. client.go
  13. client_integration_darwin_test.go
  14. client_integration_linux_test.go
  15. client_integration_test.go
  16. client_test.go
  17. conn.go
  18. CONTRIBUTORS
  19. debug.go
  20. errno_plan9.go
  21. errno_posix.go
  22. example_test.go
  23. fuzz.go
  24. go.mod
  25. go.sum
  26. LICENSE
  27. ls_formatting.go
  28. ls_formatting_test.go
  29. ls_plan9.go
  30. ls_stub.go
  31. ls_unix.go
  32. Makefile
  33. match.go
  34. packet-manager.go
  35. packet-manager_test.go
  36. packet-typing.go
  37. packet.go
  38. packet_test.go
  39. pool.go
  40. README.md
  41. release.go
  42. request-attrs.go
  43. request-attrs_test.go
  44. request-errors.go
  45. request-example.go
  46. request-interfaces.go
  47. request-plan9.go
  48. request-readme.md
  49. request-server.go
  50. request-server_test.go
  51. request-unix.go
  52. request.go
  53. request_test.go
  54. request_windows.go
  55. server.go
  56. server_integration_test.go
  57. server_nowindows_test.go
  58. server_plan9.go
  59. server_posix.go
  60. server_statvfs_darwin.go
  61. server_statvfs_impl.go
  62. server_statvfs_linux.go
  63. server_statvfs_plan9.go
  64. server_statvfs_stubs.go
  65. server_test.go
  66. server_unix.go
  67. server_windows.go
  68. server_windows_test.go
  69. sftp.go
  70. sftp_test.go
  71. stat.go
README.md

sftp

The sftp package provides support for file system operations on remote ssh servers using the SFTP subsystem. It also implements an SFTP server for serving files from the filesystem.

CI Status Go Reference

usage and examples

See https://pkg.go.dev/github.com/pkg/sftp for examples and usage.

The basic operation of the package mirrors the facilities of the os package.

The Walker interface for directory traversal is heavily inspired by Keith Rarick's fs package.

roadmap

  • There is way too much duplication in the Client methods. If there was an unmarshal(interface{}) method this would reduce a heap of the duplication.

contributing

We welcome pull requests, bug fixes and issue reports.

Before proposing a large change, first please discuss your change by raising an issue.

For API/code bugs, please include a small, self contained code example to reproduce the issue. For pull requests, remember test coverage.

We try to handle issues and pull requests with a 0 open philosophy. That means we will try to address the submission as soon as possible and will work toward a resolution. If progress can no longer be made (eg. unreproducible bug) or stops (eg. unresponsive submitter), we will close the bug.

Thanks.