Added some defines for the various exclude-function arg literals.
[rsync/rsync.git] / backup.c
index a30e7ff..97ec957 100644 (file)
--- a/backup.c
+++ b/backup.c
@@ -21,6 +21,7 @@
 #include "rsync.h"
 
 extern int verbose;
+extern int suffix_specified;
 extern char *backup_suffix;
 extern char *backup_dir;
 
@@ -197,18 +198,23 @@ static int keep_backup(char *fname)
        if (do_stat (fname, &st)) return 1;
 #endif
 
-       file = make_file(-1, fname, NULL, 1);
+       file = make_file(fname, NULL, NO_EXCLUDES);
 
        /* the file could have disappeared */
        if (!file) return 1;
 
         /* make a complete pathname for backup file */
-        if (strlen(backup_dir) + strlen(fname) > (MAXPATHLEN - 1)) {
+        if (strlen(backup_dir) + strlen(fname) + 
+               (suffix_specified ? strlen(backup_suffix) : 0) > (MAXPATHLEN - 1)) {
                 rprintf (FERROR, "keep_backup filename too long\n");
                 return 0;
         }
 
-        snprintf(keep_name, sizeof (keep_name), "%s/%s", backup_dir, fname);
+       if (suffix_specified) {
+               snprintf(keep_name, sizeof (keep_name), "%s/%s%s", backup_dir, fname, backup_suffix);
+               } else {
+               snprintf(keep_name, sizeof (keep_name), "%s/%s", backup_dir, fname);
+               }
 
 
 #ifdef HAVE_MKNOD
@@ -288,4 +294,3 @@ int make_backup(char *fname)
        else
                return (make_simple_backup(fname));
 }
-