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