summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2019-07-12 03:56:21 +0000
committerDamien Miller <djm@mindrot.org>2019-07-12 14:07:31 +1000
commita0876bd994cab9ba6e47ba2a163a4417c7597487 (patch)
tree2bf01a045922ec73f1c5b0118fdc558aee4e9f46
parentb9b0f2ac9625933db53a35b1c1ce423876630558 (diff)
upstream: print explicit "not modified" message if a file was
requested for resumed download but was considered already complete. bz#2978 ok dtucker OpenBSD-Commit-ID: f32084b26a662f16215ee4ca4a403d67e49ab986
-rw-r--r--sftp-client.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sftp-client.c b/sftp-client.c
index 73e3c2f5..4fb61819 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp-client.c,v 1.133 2019/01/24 16:52:17 dtucker Exp $ */
+/* $OpenBSD: sftp-client.c,v 1.134 2019/07/12 03:56:21 djm Exp $ */
/*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
*
@@ -1203,7 +1203,7 @@ do_download(struct sftp_conn *conn, const char *remote_path,
struct sshbuf *msg;
u_char *handle;
int local_fd = -1, write_error;
- int read_error, write_errno, reordered = 0, r;
+ int read_error, write_errno, lmodified = 0, reordered = 0, r;
u_int64_t offset = 0, size, highwater;
u_int mode, id, buflen, num_req, max_req, status = SSH2_FX_OK;
off_t progress_counter;
@@ -1373,6 +1373,7 @@ do_download(struct sftp_conn *conn, const char *remote_path,
if (len > req->len)
fatal("Received more data than asked for "
"%zu > %zu", len, req->len);
+ lmodified = 1;
if ((lseek(local_fd, req->offset, SEEK_SET) == -1 ||
atomicio(vwrite, local_fd, data, len) != len) &&
!write_error) {
@@ -1476,7 +1477,9 @@ do_download(struct sftp_conn *conn, const char *remote_path,
error("Can't set times on \"%s\": %s",
local_path, strerror(errno));
}
- if (fsync_flag) {
+ if (resume_flag && !lmodified)
+ logit("File \"%s\" was not modified", local_path);
+ else if (fsync_flag) {
debug("syncing \"%s\"", local_path);
if (fsync(local_fd) == -1)
error("Couldn't sync file \"%s\": %s",