From 2080b3d7fa72fdbe55b393c552fcde1ad2218686 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 3 Oct 2021 13:40:53 +0530 Subject: [PATCH] Print out rsync stats --- kittens/transfer/main.py | 3 ++- kittens/transfer/send.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/kittens/transfer/main.py b/kittens/transfer/main.py index e64e8aa7e..3a69f2890 100644 --- a/kittens/transfer/main.py +++ b/kittens/transfer/main.py @@ -49,7 +49,8 @@ and ask for confirmation. type=bool-set If a file on the receiving side already exists, use the rsync algorithm to update it to match the file on the sending side, potentially saving lots of bandwidth and also automatically resuming -partial transfers. +partial transfers. Note that this will actually degrade performance on fast links with not too +large files, so use with care. ''' diff --git a/kittens/transfer/send.py b/kittens/transfer/send.py index 7ba44fb59..ea0446eab 100644 --- a/kittens/transfer/send.py +++ b/kittens/transfer/send.py @@ -252,6 +252,7 @@ class ProgressTracker: self.transfered_stats_amt = 0 self.transfered_stats_interval = 0. self.started_at = 0. + self.signature_bytes = 0 self.total_reported_progress = 0 def change_active_file(self, nf: File) -> None: @@ -414,6 +415,7 @@ class SendManager: sl = file.signature_loader assert sl is not None sl.add_chunk(ftc.data) + self.progress.signature_bytes += len(ftc.data) if ftc.action is Action.end_data: sl.commit() file.start_delta_calculation() @@ -718,6 +720,16 @@ def send_main(cli_opts: TransferCLIOptions, args: List[str]) -> None: loop = Loop() handler = Send(cli_opts, files) loop.loop(handler) + if handler.manager.has_rsync: + tsf = 0 + p = handler.manager.progress + for f in files: + if f.ttype is TransmissionType.rsync: + tsf += f.file_size + print( + f'Rsync stats: Delta size: {human_size(p.total_transferred)} Signature size: {human_size(p.signature_bytes)}', + f'Total rsynced files size: {human_size(tsf)}' + ) if handler.failed_files: print(f'Transfer of {len(handler.failed_files)} out of {len(handler.manager.files)} files failed') for ff in handler.failed_files: