]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Search for double-fuzzy files only when needed
authorbenrubson <6764151+benrubson@users.noreply.github.com>
Tue, 26 May 2020 14:06:07 +0000 (16:06 +0200)
committerWayne Davison <wayne@opencoder.net>
Sat, 30 May 2020 06:13:15 +0000 (23:13 -0700)
generator.c

index b90c7ccd03f8fa8b65d7ed83b84c1f173f4749d4..dba97d85451d9f9324102edbee5f015eb61e5517 100644 (file)
@@ -1315,21 +1315,6 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                }
                parent_dirname = dn;
 
-               if (need_fuzzy_dirlist && S_ISREG(file->mode)) {
-                       int i;
-                       strlcpy(fnamecmpbuf, dn, sizeof fnamecmpbuf);
-                       for (i = 0; i < fuzzy_basis; i++) {
-                               if (i && pathjoin(fnamecmpbuf, MAXPATHLEN, basis_dir[i-1], dn) >= MAXPATHLEN)
-                                       continue;
-                               fuzzy_dirlist[i] = get_dirlist(fnamecmpbuf, -1, GDL_IGNORE_FILTER_RULES | GDL_PERHAPS_DIR);
-                               if (fuzzy_dirlist[i] && fuzzy_dirlist[i]->used == 0) {
-                                       flist_free(fuzzy_dirlist[i]);
-                                       fuzzy_dirlist[i] = NULL;
-                               }
-                       }
-                       need_fuzzy_dirlist = 0;
-               }
-
                statret = link_stat(fname, &sx.st, keep_dirlinks && is_dir);
                stat_errno = errno;
        }
@@ -1740,6 +1725,22 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                partialptr = NULL;
 
        if (statret != 0 && fuzzy_basis) {
+               if (need_fuzzy_dirlist && S_ISREG(file->mode)) {
+                       const char *dn = file->dirname ? file->dirname : ".";
+                       int i;
+                       strlcpy(fnamecmpbuf, dn, sizeof fnamecmpbuf);
+                       for (i = 0; i < fuzzy_basis; i++) {
+                               if (i && pathjoin(fnamecmpbuf, MAXPATHLEN, basis_dir[i-1], dn) >= MAXPATHLEN)
+                                       continue;
+                               fuzzy_dirlist[i] = get_dirlist(fnamecmpbuf, -1, GDL_IGNORE_FILTER_RULES | GDL_PERHAPS_DIR);
+                               if (fuzzy_dirlist[i] && fuzzy_dirlist[i]->used == 0) {
+                                       flist_free(fuzzy_dirlist[i]);
+                                       fuzzy_dirlist[i] = NULL;
+                               }
+                       }
+                       need_fuzzy_dirlist = 0;
+               }
+
                /* Sets fnamecmp_type to FNAMECMP_FUZZY or above. */
                fuzzy_file = find_fuzzy(file, fuzzy_dirlist, &fnamecmp_type);
                if (fuzzy_file) {