Skip to content

Enable direct streaming for SFTP uploads#31

Merged
VulcanoSoftware merged 1 commit into
mainfrom
fix-sftp-upload-streaming-2040905799993440024
Jul 7, 2026
Merged

Enable direct streaming for SFTP uploads#31
VulcanoSoftware merged 1 commit into
mainfrom
fix-sftp-upload-streaming-2040905799993440024

Conversation

@VulcanoSoftware

Copy link
Copy Markdown
Owner

SFTP uploads were occurring at unrealistically high speeds because they were being fully buffered in memory before being uploaded to Discord. This happened specifically when the SFTP client did not provide an expected file size during the open call.

I have updated the DCFS core and the SFTP handler to support streaming uploads with unknown file sizes. Now, all SFTP writes use the DCFSSFTPStreamingFile mechanism, which pipes data through an asyncio.Queue into the DCMsgFileContentRepository. The repository now correctly handles streams without a pre-defined partition by reading and uploading parts until the stream is exhausted.

This ensures that the SFTP client experiences backpressure from the actual Discord upload process, aligning the perceived speed with the user's internet bandwidth and avoiding excessive memory usage.


PR created automatically by Jules for task 2040905799993440024 started by @VulcanoSoftware

This change ensures that SFTP uploads are streamed directly to Discord
instead of being fully buffered in memory when the file size is unknown.

Key changes:
- Supported unknown file sizes (sentinel -1) in `DCMsgFileContentRepository.save`
  and `FileMessageFromStream.read`.
- Updated SFTP handler to always use `DCFSSFTPStreamingFile` for writes,
  enabling part-by-part streaming to Discord.
- Ensured `FileUploader` correctly partitions streams with unknown sizes.
- This applies natural backpressure via the async queue, matching the
  user's actual internet upload speed.

Co-authored-by: VulcanoSoftware <113239901+VulcanoSoftware@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@VulcanoSoftware VulcanoSoftware marked this pull request as ready for review July 7, 2026 05:12
@VulcanoSoftware VulcanoSoftware merged commit d4e014b into main Jul 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant