diff --git a/cmdline/touch.c b/cmdline/touch.c index 192dcdd4..dff3d3c0 100644 --- a/cmdline/touch.c +++ b/cmdline/touch.c @@ -90,6 +90,14 @@ int state_touch(struct snapraid_state* state) } #endif if (f == -1) { + /* + * Ignore missing files because they may have been deleted + * or moved since the last sync. Also ignore symbolic links + * which fail with ELOOP due to O_NOFOLLOW. + */ + if (errno == ENOENT || errno == ENOTDIR || errno == ELOOP) + continue; + /* LCOV_EXCL_START */ log_error(errno, "Error opening file '%s'. %s.\n", path, strerror(errno)); ++error; @@ -112,11 +120,12 @@ int state_touch(struct snapraid_state* state) } /* - * Touch only files that are still unchanged compared to + * Touch only regular files that are still unchanged compared to * the content file. Otherwise changing the timestamp here * could hide a modification from the following scan. */ - if (st.st_size != file->size + if (!S_ISREG(st.st_mode) + || st.st_size != file->size || st.st_mtime != file->mtime_sec || STAT_NSEC(&st) != file->mtime_nsec ) { diff --git a/os/mingw.c b/os/mingw.c index e41d15f5..50004651 100644 --- a/os/mingw.c +++ b/os/mingw.c @@ -877,6 +877,9 @@ void windows_errno(DWORD error) case ERROR_PATH_NOT_FOUND : /* in GetFileAttributeW() if internal path not found */ errno = ENOENT; break; + case ERROR_DIRECTORY : + errno = ENOTDIR; + break; case ERROR_ACCESS_DENIED : /* in CreateDirectoryW() if dir is scheduled for deletion */ case ERROR_CURRENT_DIRECTORY : /* in RemoveDirectoryW() if removing the current directory */ case ERROR_SHARING_VIOLATION : /* in RemoveDirectoryW() if in use */ @@ -4688,3 +4691,4 @@ void os_done(void) } #endif +