summaryrefslogtreecommitdiff
path: root/receiver.c
diff options
context:
space:
mode:
authorDavid Dykstra <dwd@samba.org>1998-11-24 19:01:24 +0000
committerDavid Dykstra <dwd@samba.org>1998-11-24 19:01:24 +0000
commit53dd3135f13728fbcfce4c85773d9fc97cfce714 (patch)
treec1ccdbedbd39f0c271154bab15064e6be7792bc8 /receiver.c
parentcd64343a7aaa1211ee330eaf9e78a33cf247637f (diff)
downloadrsync-53dd3135f13728fbcfce4c85773d9fc97cfce714.tar.gz
Backup deleted files when using --delete and --backup. Based on a
suggested patch from Kanai Makoto (kanai@hallab.co.jp).
Diffstat (limited to 'receiver.c')
-rw-r--r--receiver.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/receiver.c b/receiver.c
index 9701303b..e7a164b9 100644
--- a/receiver.c
+++ b/receiver.c
@@ -33,6 +33,8 @@ extern int cvs_exclude;
extern int io_error;
extern char *tmpdir;
extern char *compare_dest;
+extern int make_backups;
+extern char *backup_suffix;
static struct delete_list {
@@ -139,8 +141,15 @@ static void delete_files(struct file_list *flist)
S_ISDIR(local_file_list->files[i]->mode))
add_delete_entry(local_file_list->files[i]);
if (-1 == flist_find(flist,local_file_list->files[i])) {
- delete_one(local_file_list->files[i]);
- }
+ char *f = f_name(local_file_list->files[i]);
+ int k = strlen(f) - strlen(backup_suffix);
+ if (make_backups && ((k <= 0) ||
+ (strcmp(f+k,backup_suffix) != 0))) {
+ (void) make_backup(f);
+ } else {
+ delete_one(local_file_list->files[i]);
+ }
+ }
}
flist_free(local_file_list);
free(name);