Avoid touch failing on missing files deleted or moved since the last sync

This commit is contained in:
Andrea Mazzoleni 2026-09-30 15:37:52 +02:00
parent 66ae70481c
commit eb75cef0fe
2 changed files with 15 additions and 2 deletions

View file

@ -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
) {

View file

@ -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