--/**
-- * Create a file_struct for a named file by reading its stat()
-- * information and performing extensive checks against global
-- * options.
-- *
-- * @return the new file, or NULL if there was an error or this file
-- * should be excluded.
-+/* Create a file_struct for a named file by reading its stat() information
-+ * and performing extensive checks against global options.
- *
-- * @todo There is a small optimization opportunity here to avoid
-- * stat()ing the file in some circumstances, which has a certain cost.
-- * We are called immediately after doing readdir(), and so we may
-- * already know the d_type of the file. We could for example avoid
-- * statting directories if we're not recursing, but this is not a very
-- * important case. Some systems may not have d_type.
-- **/
-+ * Returns a pointer to the new file struct, or NULL if there was an error
-+ * or this file should be excluded. */
- struct file_struct *make_file(const char *fname, struct file_list *flist,
- STRUCT_STAT *stp, int flags, int filter_level)
- {
- static char *lastdir;
-- static int lastdir_len = -1;
-+ static int lastdir_len = -2;
- struct file_struct *file;
-- STRUCT_STAT st;
- char thisname[MAXPATHLEN];
- char linkname[MAXPATHLEN];
- int alloc_len, basename_len, linkname_len;
- int extra_len = file_extra_cnt * EXTRA_LEN;
- const char *basename;
- alloc_pool_t *pool;
-+ STRUCT_STAT st;
- char *bp;
-
- if (strlcpy(thisname, fname, sizeof thisname)
-@@ -1115,9 +1365,16 @@ struct file_struct *make_file(const char
- memcpy(lastdir, thisname, len);
- lastdir[len] = '\0';
- lastdir_len = len;
-+ if (always_checksum && am_sender && flist)
-+ read_checksums(lastdir);
++ if (checksum_updating)
++ write_checksums(dirname, 0);
++
+ if (checksum_flist) {
+ /* Reset the pool memory and empty the file-list array. */
+ pool_free_old(checksum_flist->file_pool,
+@@ -374,6 +480,9 @@ static void read_checksums(const char *d
+
+ checksum_flist->low = 0;
+ checksum_flist->high = -1;
++ checksum_matches = 0;
++ checksum_updates = 0;
++ regular_skipped = 0;
+
+ if (!dirname)
+ return;
+@@ -392,7 +501,7 @@ static void read_checksums(const char *d
+ while (fgets(line, sizeof line, fp)) {
+ cp = line;
+ if (protocol_version >= 30) {
+- char *alt_sum = cp;
++ alt_sum = cp;
+ if (*cp == '=')
+ while (*++cp == '=') {}
+ else
+@@ -403,7 +512,14 @@ static void read_checksums(const char *d