Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scp: track progress for larger transfers #95

Open
giftig opened this issue Jan 27, 2024 · 2 comments
Open

Scp: track progress for larger transfers #95

giftig opened this issue Jan 27, 2024 · 2 comments

Comments

@giftig
Copy link

giftig commented Jan 27, 2024

Hi, just a feature request around scp. I used this project as I ran into difficulties cross-building with bindings to libssh2 (alexcrichton/ssh2-rs#22). The APIs are very similar so it wasn't a lot of effort to swap to using ssh-rs instead, but I did notice the scp API is higher-level in this library.

I definitely appreciate the higher-level API because it allowed me to throw out 60-odd lines of low-level data-streaming code I had had to write myself with ssh2-rs and instead just invoke scp.upload(src, dest), but in my case I'm uploading relatively large files which may take a few minutes to finish. To give a progress indicator to the user I used indicatif to render a nice progress bar, transfer speed, etc. by sending updates as I processed chunks. Because ssh-rs takes care of all that and doesn't provide any updates on how it's going, I can no longer do that.

So a potential improvement to the scp API would be to either expose some of the internals of the upload as a separate lower-level API to allow hooking in like this if desired, or potentially add a version of the API which sends updates to a channel with some simple events the user can react to, e.g. details of start and finish writing each file and writing a chunk of X bytes for a given file.

@HsuJv
Copy link
Collaborator

HsuJv commented Jan 28, 2024

Maybe I can add some APIs like upload/download_with_notifier to send events via channels. Or something like upload/download_with_notify_callback to call callbacks during the process.

But this might change the current code a lot. I'll find an easiest way to approach this.

@giftig
Copy link
Author

giftig commented Jan 28, 2024

Yeah that's roughly what I had in mind; maybe an API like fn upload_with_progress(local: Path, remote: Path, notify: Channel) and you can run it async and read progress from the channel. Might need a little bit of factoring out common code but hopefully not super invasive if you just have to pass around an optional channel in the underlying stuff, for example.

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

No branches or pull requests

2 participants