Modified to depend on the partial-dir.diff.
authorWayne Davison <wayned@samba.org>
Wed, 28 Jul 2004 17:16:29 +0000 (17:16 +0000)
committerWayne Davison <wayned@samba.org>
Wed, 28 Jul 2004 17:16:29 +0000 (17:16 +0000)
compare-dest.diff
fuzzy.diff
g2r-basis-filename.diff

index a2423c6..9bd4959 100644 (file)
@@ -1,3 +1,4 @@
+Depends-On-Patch: partial-dir.diff
 Depends-On-Patch: g2r-basis-filename.diff
 
 This patch allows multiple --compare-dest or --link-dest options to be
@@ -9,18 +10,18 @@ they are suppled).
 
 Before compiling, be sure to run "make proto".
 
---- orig/generator.c   2004-07-22 00:05:38
-+++ generator.c        2004-07-19 08:32:53
-@@ -42,7 +42,7 @@ extern int size_only;
- extern int io_timeout;
+--- orig/generator.c   2004-07-28 10:14:15
++++ generator.c        2004-07-28 10:19:57
+@@ -43,7 +43,7 @@ extern int io_timeout;
  extern int protocol_version;
  extern int always_checksum;
+ extern char *partial_dir;
 -extern char *compare_dest;
 +extern char *compare_dest[];
  extern int link_dest;
  extern int whole_file;
  extern int local_server;
-@@ -79,13 +79,12 @@ static int skip_file(char *fname, struct
+@@ -80,13 +80,12 @@ static int skip_file(char *fname, struct
        if (always_checksum && S_ISREG(st->st_mode)) {
                char sum[MD4_SUM_LENGTH];
                char fnamecmpdest[MAXPATHLEN];
@@ -39,30 +40,37 @@ Before compiling, be sure to run "make proto".
                }
                file_checksum(fname,sum,st->st_size);
                return memcmp(sum, file->u.sum, protocol_version < 21 ? 2
-@@ -413,13 +412,18 @@ static void recv_generator(char *fname, 
+@@ -422,11 +421,18 @@ static void recv_generator(char *fname, 
  
        fnamecmp = fname;
  
 -      if (statret == -1 && compare_dest != NULL) {
 +      if (statret == -1 && compare_dest[0] != NULL) {
                /* try the file at compare_dest instead */
-               int saveerrno = errno;
 -              pathjoin(fnamecmpbuf, sizeof fnamecmpbuf, compare_dest, fname);
--              statret = link_stat(fnamecmpbuf, &st, 0);
--              if (!S_ISREG(st.st_mode))
--                      statret = -1;
+-              if (link_stat(fnamecmpbuf, &st, 0) == 0
+-                  && S_ISREG(st.st_mode)) {
 +              int i;
 +              for (i = 0; compare_dest[i] != NULL; i++) {
 +                      pathjoin(fnamecmpbuf, sizeof fnamecmpbuf, compare_dest[i], fname);
-+                      if ((statret = link_stat(fnamecmpbuf, &st, 0)) == 0) {
-+                              if (S_ISREG(st.st_mode))
-+                                      break;
-+                              statret = -1;
++                      if (link_stat(fnamecmpbuf, &st, 0) == 0
++                          && S_ISREG(st.st_mode)) {
++                              statret = 0;
++                              break;
 +                      }
 +              }
-               if (statret == -1) {
-                       errno = saveerrno;
++              if (statret == 0) {
+ #if HAVE_LINK
+                       if (link_dest && !dry_run) {
+                               if (do_link(fnamecmpbuf, fname) < 0) {
+@@ -442,7 +448,6 @@ static void recv_generator(char *fname, 
+                       } else
+ #endif
+                               fnamecmp = fnamecmpbuf;
+-                      statret = 0;
+               } else
                        *fnamecmpbuf = '\0';
+       } else
 --- orig/main.c        2004-07-22 00:10:43
 +++ main.c     2004-07-22 00:30:38
 @@ -58,7 +58,7 @@ extern int filesfrom_fd;
@@ -83,19 +91,24 @@ Before compiling, be sure to run "make proto".
  
        if (preserve_hard_links)
                init_hard_links(flist);
---- orig/options.c     2004-07-23 17:16:13
-+++ options.c  2004-07-03 17:33:30
-@@ -118,7 +118,8 @@ unsigned int backup_dir_remainder;
+--- orig/options.c     2004-07-26 16:43:48
++++ options.c  2004-07-23 22:04:42
+@@ -114,12 +114,13 @@ int write_batch = 0;
+ int read_batch = 0;
+ int backup_dir_len = 0;
+ int backup_suffix_len;
++int num_comp_dest = 0;
+ unsigned int backup_dir_remainder;
  
  char *backup_suffix = NULL;
  char *tmpdir = NULL;
+ char *partial_dir = NULL;
 -char *compare_dest = NULL;
 +char *compare_dest[MAX_COMP_DEST+1];
-+int num_comp_dest = 0;
  char *config_file = NULL;
  char *shell_cmd = NULL;
  char *log_format = NULL;
-@@ -139,6 +140,7 @@ char *batch_name = NULL;
+@@ -140,6 +141,7 @@ char *batch_name = NULL;
  
  static int daemon_opt;   /* sets am_daemon after option error-reporting */
  static int modify_window_set;
@@ -103,7 +116,7 @@ Before compiling, be sure to run "make proto".
  
  /** Local address to bind.  As a character string because it's
   * interpreted by the IPv6 layer: should be a numeric IP4 or IP6
-@@ -315,7 +317,7 @@ void usage(enum logcode F)
+@@ -317,7 +319,7 @@ void usage(enum logcode F)
  }
  
  enum {OPT_VERSION = 1000, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
@@ -112,7 +125,7 @@ Before compiling, be sure to run "make proto".
        OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW,
        OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_TIMEOUT,
        OPT_REFUSED_BASE = 9000};
-@@ -374,8 +376,8 @@ static struct poptOption long_options[] 
+@@ -376,8 +378,8 @@ static struct poptOption long_options[] 
    {"max-delete",       0,  POPT_ARG_INT,    &max_delete, 0, 0, 0 },
    {"timeout",          0,  POPT_ARG_INT,    &io_timeout, OPT_TIMEOUT, 0, 0 },
    {"temp-dir",        'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 },
@@ -123,7 +136,7 @@ Before compiling, be sure to run "make proto".
    /* TODO: Should this take an optional int giving the compression level? */
    {"compress",        'z', POPT_ARG_NONE,   &do_compression, 0, 0, 0 },
    {"daemon",           0,  POPT_ARG_NONE,   &daemon_opt, 0, 0, 0 },
-@@ -591,8 +593,36 @@ int parse_arguments(int *argc, const cha
+@@ -594,8 +596,36 @@ int parse_arguments(int *argc, const cha
                                select_timeout = io_timeout;
                        break;
  
@@ -160,7 +173,7 @@ Before compiling, be sure to run "make proto".
                        link_dest = 1;
                        break;
  #else
-@@ -690,6 +720,11 @@ int parse_arguments(int *argc, const cha
+@@ -693,6 +723,11 @@ int parse_arguments(int *argc, const cha
                exit_cleanup(RERR_SYNTAX);
        }
  
@@ -172,16 +185,16 @@ Before compiling, be sure to run "make proto".
        if (archive_mode) {
                if (!files_from)
                        recurse = 1;
-@@ -718,8 +753,6 @@ int parse_arguments(int *argc, const cha
-                       (*argv)[i] = alloc_sanitize_path((*argv)[i], NULL);
-               if (tmpdir)
+@@ -723,8 +758,6 @@ int parse_arguments(int *argc, const cha
                        tmpdir = alloc_sanitize_path(tmpdir, curr_dir);
+               if (partial_dir)
+                       partial_dir = alloc_sanitize_path(partial_dir, curr_dir);
 -              if (compare_dest)
 -                      compare_dest = alloc_sanitize_path(compare_dest, curr_dir);
                if (backup_dir)
                        backup_dir = alloc_sanitize_path(backup_dir, curr_dir);
                if (files_from)
-@@ -825,8 +858,8 @@ int parse_arguments(int *argc, const cha
+@@ -836,8 +869,8 @@ int parse_arguments(int *argc, const cha
   **/
  void server_options(char **args,int *argc)
  {
@@ -191,7 +204,7 @@ Before compiling, be sure to run "make proto".
        char *arg;
  
        int i, x;
-@@ -1004,13 +1037,16 @@ void server_options(char **args,int *arg
+@@ -1018,13 +1051,16 @@ void server_options(char **args,int *arg
                args[ac++] = tmpdir;
        }
  
@@ -211,17 +224,17 @@ Before compiling, be sure to run "make proto".
        }
  
        if (files_from && (!am_sender || remote_filesfrom_file)) {
---- orig/receiver.c    2004-07-22 00:20:50
-+++ receiver.c 2004-07-03 20:14:37
-@@ -38,7 +38,6 @@ extern int preserve_perms;
- extern int cvs_exclude;
+--- orig/receiver.c    2004-07-23 21:59:07
++++ receiver.c 2004-07-23 22:05:04
+@@ -39,7 +39,6 @@ extern int cvs_exclude;
  extern int io_error;
  extern char *tmpdir;
+ extern char *partial_dir;
 -extern char *compare_dest;
  extern int make_backups;
  extern int do_progress;
  extern char *backup_dir;
---- orig/rsync.h       2004-07-23 17:16:13
+--- orig/rsync.h       2004-07-27 23:23:54
 +++ rsync.h    2004-07-03 17:33:30
 @@ -98,6 +98,8 @@
  
index 3f93023..4e3cd81 100644 (file)
@@ -1,3 +1,4 @@
+Depends-On-Patch: partial-dir.diff
 Depends-On-Patch: g2r-basis-filename.diff
 
 The changes to generator.c were greatly simplified, making the patch
@@ -6,17 +7,17 @@ Very lightly tested.
 
 Be sure to run "make proto" before "make".
 
---- orig/generator.c   2004-07-22 00:05:38
-+++ generator.c        2004-07-20 21:49:24
+--- orig/generator.c   2004-07-28 10:14:15
++++ generator.c        2004-07-28 10:23:12
 @@ -41,6 +41,7 @@ extern int ignore_times;
  extern int size_only;
  extern int io_timeout;
  extern int protocol_version;
 +extern int fuzzy;
  extern int always_checksum;
+ extern char *partial_dir;
  extern char *compare_dest;
- extern int link_dest;
-@@ -248,6 +249,94 @@ static void generate_and_send_sums(int f
+@@ -249,6 +250,94 @@ static void generate_and_send_sums(int f
  }
  
  
@@ -111,16 +112,16 @@ Be sure to run "make proto" before "make".
  
  /*
   * Acts on file number @p i from @p flist, whose name is @p fname.
-@@ -262,7 +351,7 @@ static void recv_generator(char *fname, 
+@@ -263,7 +352,7 @@ static void recv_generator(char *fname, 
  {
        int fd = -1;
        STRUCT_STAT st;
--      int statret;
-+      int statret, fuzzy_file = 0;
+-      int statret, stat_errno;
++      int statret, stat_errno, fuzzy_file = 0;
        char *fnamecmp;
        char fnamecmpbuf[MAXPATHLEN];
  
-@@ -441,6 +530,14 @@ static void recv_generator(char *fname, 
+@@ -448,6 +537,14 @@ static void recv_generator(char *fname, 
        } else
                *fnamecmpbuf = '\0';
  
@@ -132,10 +133,10 @@ Be sure to run "make proto" before "make".
 +                      fuzzy_file = 1;
 +      }
 +
-       if (statret == -1) {
-               if (preserve_hard_links && hard_link_check(file, HL_SKIP))
+       if (statret == 0 && !S_ISREG(st.st_mode)) {
+               if (delete_file(fname) != 0)
                        return;
-@@ -478,7 +575,7 @@ static void recv_generator(char *fname, 
+@@ -481,7 +578,7 @@ static void recv_generator(char *fname, 
                return;
        }
  
@@ -163,7 +164,7 @@ Be sure to run "make proto" before "make".
  
        if (preserve_hard_links)
                init_hard_links(flist);
---- orig/options.c     2004-07-23 17:16:13
+--- orig/options.c     2004-07-26 16:43:48
 +++ options.c  2004-07-16 20:14:12
 @@ -85,6 +85,7 @@ int safe_symlinks = 0;
  int copy_unsafe_links = 0;
@@ -173,7 +174,7 @@ Be sure to run "make proto" before "make".
  size_t bwlimit_writemax = 0;
  int delete_after = 0;
  int only_existing = 0;
-@@ -277,6 +278,7 @@ void usage(enum logcode F)
+@@ -279,6 +280,7 @@ void usage(enum logcode F)
    rprintf(F," -T, --temp-dir=DIR          create temporary files in directory DIR\n");
    rprintf(F,"     --compare-dest=DIR      also compare destination files relative to DIR\n");
    rprintf(F,"     --link-dest=DIR         create hardlinks to DIR for unchanged files\n");
@@ -181,7 +182,7 @@ Be sure to run "make proto" before "make".
    rprintf(F," -P                          equivalent to --partial --progress\n");
    rprintf(F," -z, --compress              compress file data\n");
    rprintf(F," -C, --cvs-exclude           auto ignore files in the same way CVS does\n");
-@@ -376,6 +378,7 @@ static struct poptOption long_options[] 
+@@ -378,6 +380,7 @@ static struct poptOption long_options[] 
    {"temp-dir",        'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 },
    {"compare-dest",     0,  POPT_ARG_STRING, &compare_dest, 0, 0, 0 },
    {"link-dest",        0,  POPT_ARG_STRING, &compare_dest,  OPT_LINK_DEST, 0, 0 },
@@ -189,7 +190,7 @@ Be sure to run "make proto" before "make".
    /* TODO: Should this take an optional int giving the compression level? */
    {"compress",        'z', POPT_ARG_NONE,   &do_compression, 0, 0, 0 },
    {"daemon",           0,  POPT_ARG_NONE,   &daemon_opt, 0, 0, 0 },
-@@ -1025,6 +1028,9 @@ void server_options(char **args,int *arg
+@@ -1039,6 +1042,9 @@ void server_options(char **args,int *arg
                }
        }
  
@@ -199,19 +200,19 @@ Be sure to run "make proto" before "make".
        *argc = ac;
        return;
  
---- orig/receiver.c    2004-07-22 00:20:50
-+++ receiver.c 2004-07-03 20:09:05
-@@ -38,7 +38,6 @@ extern int preserve_perms;
- extern int cvs_exclude;
+--- orig/receiver.c    2004-07-23 21:59:07
++++ receiver.c 2004-07-23 22:08:03
+@@ -39,7 +39,6 @@ extern int cvs_exclude;
  extern int io_error;
  extern char *tmpdir;
+ extern char *partial_dir;
 -extern char *compare_dest;
  extern int make_backups;
  extern int do_progress;
  extern char *backup_dir;
---- orig/rsync.yo      2004-07-23 17:16:13
+--- orig/rsync.yo      2004-07-28 02:26:19
 +++ rsync.yo   2004-07-03 19:27:25
-@@ -326,6 +326,7 @@ verb(
+@@ -327,6 +327,7 @@ verb(
   -T  --temp-dir=DIR          create temporary files in directory DIR
       --compare-dest=DIR      also compare received files relative to DIR
       --link-dest=DIR         create hardlinks to DIR for unchanged files
index 195f743..0ff296a 100644 (file)
@@ -1,3 +1,5 @@
+Depends-On-Patch: partial-dir.diff
+
 Added a pipe from the generator to the receiver that communicates
 what basis file we used to generate the file data (if it was not
 the default name).  This optimizes away the basis-file search in
@@ -7,9 +9,9 @@ support for multiple --compare-dest options).
 
 You must run "make proto" before compiling.
 
---- orig/generator.c   2004-07-23 17:16:12
-+++ generator.c        2004-07-22 00:05:38
-@@ -258,9 +258,9 @@ static void generate_and_send_sums(int f
+--- orig/generator.c   2004-07-28 09:58:28
++++ generator.c        2004-07-28 10:14:15
+@@ -259,9 +259,9 @@ static void generate_and_send_sums(int f
   * out.  It might be wrong.
   */
  static void recv_generator(char *fname, struct file_struct *file, int i,
@@ -19,75 +21,51 @@ You must run "make proto" before compiling.
 -      int fd;
 +      int fd = -1;
        STRUCT_STAT st;
-       int statret;
+       int statret, stat_errno;
        char *fnamecmp;
-@@ -420,8 +420,10 @@ static void recv_generator(char *fname, 
-               statret = link_stat(fnamecmpbuf, &st, 0);
-               if (!S_ISREG(st.st_mode))
-                       statret = -1;
--              if (statret == -1)
-+              if (statret == -1) {
-                       errno = saveerrno;
-+                      *fnamecmpbuf = '\0';
-+              }
- #if HAVE_LINK
-               else if (link_dest && !dry_run) {
-                       if (do_link(fnamecmpbuf, fname) != 0) {
-@@ -429,22 +431,22 @@ static void recv_generator(char *fname, 
-                                       rsyserr(FINFO, errno, "link %s => %s",
-                                               fnamecmpbuf, fname);
-                               }
--                      }
--                      fnamecmp = fnamecmpbuf;
-+                              fnamecmp = fnamecmpbuf;
-+                      } else
-+                              *fnamecmpbuf = '\0';
-               }
+@@ -437,13 +437,16 @@ static void recv_generator(char *fname, 
+                                                       safe_fname(fname));
+                                       }
+                                       fnamecmp = fnamecmpbuf;
+-                              }
++                              } else
++                                      *fnamecmpbuf = '\0';
+                       } else
  #endif
-               else
-                       fnamecmp = fnamecmpbuf;
+                               fnamecmp = fnamecmpbuf;
+                       statret = 0;
+-              }
 -      }
++              } else
++                      *fnamecmpbuf = '\0';
 +      } else
 +              *fnamecmpbuf = '\0';
  
+       if (statret == 0 && !S_ISREG(st.st_mode)) {
+               if (delete_file(fname) != 0)
+@@ -455,11 +458,9 @@ static void recv_generator(char *fname, 
        if (statret == -1) {
                if (preserve_hard_links && hard_link_check(file, HL_SKIP))
                        return;
--              if (errno == ENOENT) {
+-              if (stat_errno == ENOENT) {
 -                      write_int(f_out,i);
 -                      if (!dry_run && !read_batch)
 -                              write_sum_head(f_out, NULL);
 -              } else if (verbose > 1) {
-+              if (errno == ENOENT)
++              if (stat_errno == ENOENT)
 +                      goto notify_others;
 +              if (verbose > 1) {
-                       rsyserr(FERROR, errno,
-                               "recv_generator: failed to open %s",
+                       rsyserr(FERROR, stat_errno,
+                               "recv_generator: failed to stat %s",
                                full_fname(fname));
-@@ -453,26 +455,23 @@ static void recv_generator(char *fname, 
-       }
-       if (!S_ISREG(st.st_mode)) {
--              if (delete_file(fname) != 0) {
-+              if (delete_file(fname) != 0)
-                       return;
--              }
-               /* now pretend the file didn't exist */
-               if (preserve_hard_links && hard_link_check(file, HL_SKIP))
-                       return;
--              write_int(f_out,i);
--              if (!dry_run && !read_batch)
--                      write_sum_head(f_out, NULL);
--              return;
-+              statret = -1;
-+              goto notify_others;
+@@ -467,13 +468,13 @@ static void recv_generator(char *fname, 
+               return;
        }
  
 -      if (opt_ignore_existing && fnamecmp == fname) {
 +      if (opt_ignore_existing && !*fnamecmpbuf) {
                if (verbose > 1)
-                       rprintf(FINFO,"%s exists\n",fname);
+                       rprintf(FINFO, "%s exists\n", safe_fname(fname));
                return;
        }
  
@@ -95,8 +73,8 @@ You must run "make proto" before compiling.
 +      if (update_only && !*fnamecmpbuf
            && cmp_modtime(st.st_mtime, file->modtime) > 0) {
                if (verbose > 1)
-                       rprintf(FINFO,"%s is newer\n",fname);
-@@ -480,21 +479,17 @@ static void recv_generator(char *fname, 
+                       rprintf(FINFO, "%s is newer\n", safe_fname(fname));
+@@ -481,21 +482,17 @@ static void recv_generator(char *fname, 
        }
  
        if (skip_file(fname, file, &st)) {
@@ -122,9 +100,9 @@ You must run "make proto" before compiling.
 +      if (read_batch)
 +              goto notify_others;
  
-       /* open the file */
-       fd = do_open(fnamecmp, O_RDONLY, 0);
-@@ -505,9 +500,8 @@ static void recv_generator(char *fname, 
+       if (partial_dir) {
+               STRUCT_STAT st2;
+@@ -516,9 +513,8 @@ static void recv_generator(char *fname, 
                /* pretend the file didn't exist */
                if (preserve_hard_links && hard_link_check(file, HL_SKIP))
                        return;
@@ -136,7 +114,7 @@ You must run "make proto" before compiling.
        }
  
        if (verbose > 3) {
-@@ -518,14 +512,41 @@ static void recv_generator(char *fname, 
+@@ -529,14 +525,41 @@ static void recv_generator(char *fname, 
        if (verbose > 2)
                rprintf(FINFO, "generating and sending sums for %d\n", i);
  
@@ -182,7 +160,7 @@ You must run "make proto" before compiling.
  {
        int i;
        int phase = 0;
-@@ -566,7 +587,7 @@ void generate_files(int f_out, struct fi
+@@ -577,7 +600,7 @@ void generate_files(int f_out, struct fi
                }
  
                recv_generator(local_name ? local_name : f_name_to(file, fbuf),
@@ -191,7 +169,7 @@ You must run "make proto" before compiling.
        }
  
        phase++;
-@@ -583,7 +604,7 @@ void generate_files(int f_out, struct fi
+@@ -594,7 +617,7 @@ void generate_files(int f_out, struct fi
        while ((i = get_redo_num()) != -1) {
                struct file_struct *file = flist->files[i];
                recv_generator(local_name ? local_name : f_name_to(file, fbuf),
@@ -200,7 +178,7 @@ You must run "make proto" before compiling.
        }
  
        phase++;
-@@ -602,7 +623,7 @@ void generate_files(int f_out, struct fi
+@@ -613,7 +636,7 @@ void generate_files(int f_out, struct fi
                if (!file->basename || !S_ISDIR(file->mode))
                        continue;
                recv_generator(local_name ? local_name : f_name(file),
@@ -209,7 +187,7 @@ You must run "make proto" before compiling.
        }
  
        if (verbose > 2)
---- orig/main.c        2004-07-23 17:16:13
+--- orig/main.c        2004-07-24 16:52:09
 +++ main.c     2004-07-22 00:10:43
 @@ -58,6 +58,7 @@ extern int filesfrom_fd;
  extern pid_t cleanup_child_pid;
@@ -283,9 +261,9 @@ You must run "make proto" before compiling.
  
        get_redo_num(); /* Read final MSG_DONE and any prior messages. */
        report(-1);
---- orig/receiver.c    2004-07-23 17:16:13
-+++ receiver.c 2004-07-22 00:20:50
-@@ -320,6 +320,30 @@ static int receive_data(int f_in, char *
+--- orig/receiver.c    2004-07-27 23:26:20
++++ receiver.c 2004-07-23 21:59:07
+@@ -325,6 +325,30 @@ static int receive_data(int f_in, char *
  }
  
  
@@ -316,7 +294,7 @@ You must run "make proto" before compiling.
  static void discard_receive_data(int f_in, OFF_T length)
  {
        receive_data(f_in, NULL, -1, 0, NULL, -1, length);
-@@ -330,7 +354,8 @@ static void discard_receive_data(int f_i
+@@ -335,7 +359,8 @@ static void discard_receive_data(int f_i
   * main routine for receiver process.
   *
   * Receiver process runs on the same host as the generator process. */
@@ -326,7 +304,7 @@ You must run "make proto" before compiling.
  {
        int next_gen_i = -1;
        int fd1,fd2;
-@@ -359,8 +384,15 @@ int recv_files(int f_in, struct file_lis
+@@ -364,8 +389,15 @@ int recv_files(int f_in, struct file_lis
                i = read_int(f_in);
                if (i == -1) {
                        if (read_batch) {
@@ -344,12 +322,8 @@ You must run "make proto" before compiling.
                                next_gen_i = -1;
                        }
  
-@@ -406,10 +438,12 @@ int recv_files(int f_in, struct file_lis
-               if (verbose > 2)
-                       rprintf(FINFO,"recv_files(%s)\n",fname);
+@@ -413,6 +445,10 @@ int recv_files(int f_in, struct file_lis
  
--              fnamecmp = fname;
--
                if (read_batch) {
                        while (i > next_gen_i) {
 +                              if (f_in_name >= 0 && next_gen_i >= 0) {
@@ -359,7 +333,7 @@ You must run "make proto" before compiling.
                                next_gen_i = read_int(batch_gen_fd);
                                if (next_gen_i == -1)
                                        next_gen_i = flist->count;
-@@ -420,8 +454,14 @@ int recv_files(int f_in, struct file_lis
+@@ -423,8 +459,14 @@ int recv_files(int f_in, struct file_lis
                                discard_receive_data(f_in, file->length);
                                continue;
                        }
@@ -374,9 +348,24 @@ You must run "make proto" before compiling.
                if (server_exclude_list.head
                    && check_exclude(&server_exclude_list, fname,
                                     S_ISDIR(file->mode)) < 0) {
-@@ -437,14 +477,6 @@ int recv_files(int f_in, struct file_lis
+@@ -437,13 +479,7 @@ int recv_files(int f_in, struct file_lis
+                       continue;
+               }
+-              if (partial_dir) {
+-                      if ((partialptr = partial_dir_fname(fname)) != NULL)
+-                              fnamecmp = partialptr;
+-                      else
+-                              fnamecmp = fname;
+-              } else
+-                      fnamecmp = partialptr = fname;
++              partialptr = partial_dir ? partial_dir_fname(fname) : fname;
                /* open the file */
                fd1 = do_open(fnamecmp, O_RDONLY, 0);
+@@ -453,14 +489,6 @@ int recv_files(int f_in, struct file_lis
+                       fd1 = do_open(fnamecmp, O_RDONLY, 0);
+               }
  
 -              if (fd1 == -1 && compare_dest != NULL) {
 -                      /* try the file at compare_dest instead */