Commit 4e9c7fae authored by Wayne Davison's avatar Wayne Davison

The suffix must be non-empty if the backup-dir is the same as the dest

dir.
parent 3696674b
...@@ -825,10 +825,8 @@ static int do_recv(int f_in, int f_out, char *local_name) ...@@ -825,10 +825,8 @@ static int do_recv(int f_in, int f_out, char *local_name)
exit_cleanup(RERR_SYNTAX); exit_cleanup(RERR_SYNTAX);
if (ret) if (ret)
rprintf(FINFO, "Created backup_dir %s\n", backup_dir_buf); rprintf(FINFO, "Created backup_dir %s\n", backup_dir_buf);
else if (INFO_GTE(BACKUP, 1)) { else if (INFO_GTE(BACKUP, 1))
char *dir = *backup_dir_buf ? backup_dir_buf : "."; rprintf(FINFO, "backup_dir is %s\n", backup_dir_buf);
rprintf(FINFO, "backup_dir is %s\n", dir);
}
} }
io_flush(NORMAL_FLUSH); io_flush(NORMAL_FLUSH);
......
...@@ -2008,13 +2008,21 @@ int parse_arguments(int *argc_p, const char ***argv_p) ...@@ -2008,13 +2008,21 @@ int parse_arguments(int *argc_p, const char ***argv_p)
"the --backup-dir path is WAY too long.\n"); "the --backup-dir path is WAY too long.\n");
return 0; return 0;
} }
if (backup_dir_len && backup_dir_buf[backup_dir_len - 1] != '/') { if (!backup_dir_len) {
backup_dir_len = -1;
backup_dir = NULL;
} else if (backup_dir_buf[backup_dir_len - 1] != '/') {
backup_dir_buf[backup_dir_len++] = '/'; backup_dir_buf[backup_dir_len++] = '/';
backup_dir_buf[backup_dir_len] = '\0'; backup_dir_buf[backup_dir_len] = '\0';
} }
}
if (backup_dir) {
/* No need for a suffix or a protect rule. */
} else if (!backup_suffix_len && (!am_server || !am_sender)) { } else if (!backup_suffix_len && (!am_server || !am_sender)) {
snprintf(err_buf, sizeof err_buf, snprintf(err_buf, sizeof err_buf,
"--suffix cannot be a null string without --backup-dir\n"); "--suffix cannot be empty %s\n", backup_dir_len < 0
? "when --backup-dir is the same as the dest dir"
: "without a --backup-dir");
return 0; return 0;
} else if (make_backups && delete_mode && !delete_excluded && !am_server) { } else if (make_backups && delete_mode && !delete_excluded && !am_server) {
snprintf(backup_dir_buf, sizeof backup_dir_buf, snprintf(backup_dir_buf, sizeof backup_dir_buf,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment