alailsonko opened a new pull request, #629:
URL: https://github.com/apache/guacamole-server/pull/629

   This pull request significantly improves the efficiency and reliability of 
SFTP file uploads by introducing buffered uploads and robust error handling. 
Instead of writing each incoming data blob directly to the remote file, uploads 
are now buffered in memory and flushed in larger chunks, reducing the number of 
SFTP write operations and handling partial writes more gracefully. The code 
also introduces a per-upload state structure to track progress and errors, and 
ensures proper cleanup at the end of each upload.
   
   **Buffered SFTP uploads**
   
   * Introduced a new upload state struct (`guac_common_ssh_sftp_upload_state`) 
to manage buffered data, the SFTP file handle, and error status for each upload 
stream.
   * Implemented a buffered upload mechanism: incoming data is accumulated in a 
256KB buffer and only flushed to the remote file when full or at the end of the 
upload, reducing the number of SFTP write calls and handling partial writes 
robustly. 
[[1]](diffhunk://#diff-9aaddd9aa496d35464c22e57e1cf517747cf1c4da92ccaa16cded8f3bca2cfcbR37-R98)
 
[[2]](diffhunk://#diff-9aaddd9aa496d35464c22e57e1cf517747cf1c4da92ccaa16cded8f3bca2cfcbR372-R434)
   * Enhanced error handling: errors during write or flush are tracked in the 
upload state, and subsequent blobs or end-of-stream events respond with 
appropriate error messages. 
[[1]](diffhunk://#diff-9aaddd9aa496d35464c22e57e1cf517747cf1c4da92ccaa16cded8f3bca2cfcbR372-R434)
 
[[2]](diffhunk://#diff-9aaddd9aa496d35464c22e57e1cf517747cf1c4da92ccaa16cded8f3bca2cfcbR456-R496)
   * Modified the SFTP blob and end handlers to use the new buffered upload 
logic and state, including proper acknowledgment and freeing of resources at 
the end of uploads. 
[[1]](diffhunk://#diff-9aaddd9aa496d35464c22e57e1cf517747cf1c4da92ccaa16cded8f3bca2cfcbR372-R434)
 
[[2]](diffhunk://#diff-9aaddd9aa496d35464c22e57e1cf517747cf1c4da92ccaa16cded8f3bca2cfcbR456-R496)
   * Updated stream initialization in both file and put handlers to allocate 
and initialize the new upload state, replacing direct storage of the SFTP file 
handle. 
[[1]](diffhunk://#diff-9aaddd9aa496d35464c22e57e1cf517747cf1c4da92ccaa16cded8f3bca2cfcbL437-R571)
 
[[2]](diffhunk://#diff-9aaddd9aa496d35464c22e57e1cf517747cf1c4da92ccaa16cded8f3bca2cfcbL920-R1059)
   
   **Related Jira Item**
   - 
https://issues.apache.org/jira/projects/GUACAMOLE/issues/GUACAMOLE-2180?filter=allopenissues


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to