From 37e7ca2faa452a659a8181d3d7455433d5425d92 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 14 Oct 2014 23:01:01 +0200 Subject: [PATCH] Removes warning messages in Windwos about not updated metadata. --- cmdline/import.c | 5 ++++- cmdline/scan.c | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/cmdline/import.c b/cmdline/import.c index adfda914..96a0a4f0 100644 --- a/cmdline/import.c +++ b/cmdline/import.c @@ -267,7 +267,10 @@ static void import_dir(struct snapraid_state* state, const char* dir) dirent_lstat(dd, &st); /* if the st_mode field is missing, takes care to fill it using normal lstat() */ - /* at now this can happen only in Windows */ + /* at now this can happen only in Windows (with HAVE_STRUCT_DIRENT_D_STAT defined), */ + /* becasue we use a directory reading method that doesn't read info about ReparsePoint. */ + /* Note that here we cannot call here lstat_sync(), because we don't know what kind */ + /* of file is it, and lstat_sync() doesn't always work */ if (st.st_mode == 0) { if (lstat(path, &st) != 0) { /* LCOV_EXCL_START */ diff --git a/cmdline/scan.c b/cmdline/scan.c index 495cd150..bbddf1f3 100644 --- a/cmdline/scan.c +++ b/cmdline/scan.c @@ -355,15 +355,28 @@ static void scan_file_refresh(struct snapraid_scan* scan, const char* sub, struc if (st->st_mtime != synced_st.st_mtime || st->st_mtimensec != synced_st.st_mtimensec ) { +#ifndef _WIN32 + /* + * In Windows having different metadata is expected with open files + * because the metadata in the directory is updated only when the file + * is closed. + * + * See also: + * Why is the file size reported incorrectly for files that are still being written to? + * http://blogs.msdn.com/b/oldnewthing/archive/2011/12/26/10251026.aspx + */ fprintf(stderr, "WARNING! Detected uncached time change for file '%s'\n", sub); fprintf(stderr, "It's better if you run SnapRAID without other processes running.\n"); +#endif st->st_mtime = synced_st.st_mtime; st->st_mtimensec = synced_st.st_mtimensec; } if (st->st_size != synced_st.st_size) { +#ifndef _WIN32 fprintf(stderr, "WARNING! Detected uncached size change for file '%s'\n", sub); fprintf(stderr, "It's better if you run SnapRAID without other processes running.\n"); +#endif st->st_size = synced_st.st_size; } @@ -1191,8 +1204,10 @@ static int scan_dir(struct snapraid_scan* scan, int output, const char* dir, con #if HAVE_STRUCT_DIRENT_D_STAT /* if the st_mode field is missing, takes care to fill it using normal lstat() */ - /* at now this can happen only in Windows, but we cannot call here lstat_sync(), */ - /* because we don't know what kind of file is it, and lstat_sync() doesn't always work */ + /* at now this can happen only in Windows (with HAVE_STRUCT_DIRENT_D_STAT defined), */ + /* becasue we use a directory reading method that doesn't read info about ReparsePoint. */ + /* Note that here we cannot call here lstat_sync(), because we don't know what kind */ + /* of file is it, and lstat_sync() doesn't always work */ if (st->st_mode == 0) { if (lstat(path_next, st) != 0) { /* LCOV_EXCL_START */