[openssh-commits] [openssh] 02/08: upstream: show only the final path component in the progress meter;

git+noreply at mindrot.org git+noreply at mindrot.org
Tue Aug 10 12:48:00 AEST 2021


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 986abe94d481a1e82a01747360bd767b96b41eda
Author: djm at openbsd.org <djm at openbsd.org>
Date:   Mon Aug 9 07:16:09 2021 +0000

    upstream: show only the final path component in the progress meter;
    
    more useful with long paths (that may truncate) and better matches
    traditional scp behaviour; spotted by naddy@ ok deraadt@
    
    OpenBSD-Commit-ID: 26b544d0074f03ebb8a3ebce42317d8d7ee291a3
---
 sftp-client.c | 34 ++++++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/sftp-client.c b/sftp-client.c
index 943d142f..ce31c35a 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp-client.c,v 1.152 2021/08/07 01:55:01 djm Exp $ */
+/* $OpenBSD: sftp-client.c,v 1.153 2021/08/09 07:16:09 djm Exp $ */
 /*
  * Copyright (c) 2001-2004 Damien Miller <djm at openbsd.org>
  *
@@ -1370,6 +1370,19 @@ send_open(struct sftp_conn *conn, const char *path, const char *tag,
 	return 0;
 }
 
+static const char *
+progress_meter_path(const char *path)
+{
+	const char *progresspath;
+
+	if ((progresspath = strrchr(path, '/')) == NULL)
+		return path;
+	progresspath++;
+	if (*progresspath == '\0')
+		return path;
+	return progresspath;
+}
+
 int
 do_download(struct sftp_conn *conn, const char *remote_path,
     const char *local_path, Attrib *a, int preserve_flag, int resume_flag,
@@ -1453,8 +1466,10 @@ do_download(struct sftp_conn *conn, const char *remote_path,
 	max_req = 1;
 	progress_counter = offset;
 
-	if (showprogress && size != 0)
-		start_progress_meter(remote_path, size, &progress_counter);
+	if (showprogress && size != 0) {
+		start_progress_meter(progress_meter_path(remote_path),
+		    size, &progress_counter);
+	}
 
 	if ((msg = sshbuf_new()) == NULL)
 		fatal_f("sshbuf_new failed");
@@ -1844,9 +1859,10 @@ do_upload(struct sftp_conn *conn, const char *local_path,
 
 	/* Read from local and write to remote */
 	offset = progress_counter = (resume ? c->size : 0);
-	if (showprogress)
-		start_progress_meter(local_path, sb.st_size,
-		    &progress_counter);
+	if (showprogress) {
+		start_progress_meter(progress_meter_path(local_path),
+		    sb.st_size, &progress_counter);
+	}
 
 	if ((msg = sshbuf_new()) == NULL)
 		fatal_f("sshbuf_new failed");
@@ -2203,8 +2219,10 @@ do_crossload(struct sftp_conn *from, struct sftp_conn *to,
 	max_req = 1;
 	progress_counter = 0;
 
-	if (showprogress && size != 0)
-		start_progress_meter(from_path, size, &progress_counter);
+	if (showprogress && size != 0) {
+		start_progress_meter(progress_meter_path(from_path),
+		    size, &progress_counter);
+	}
 	if ((msg = sshbuf_new()) == NULL)
 		fatal_f("sshbuf_new failed");
 	while (num_req > 0 || max_req > 0) {

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list