Avoid saving the content file in touch if nothing changed

This commit is contained in:
Andrea Mazzoleni 2026-06-10 00:54:45 +02:00
parent e4aa186b1a
commit bf2657b76a
2 changed files with 30 additions and 6 deletions

View file

@ -1903,11 +1903,18 @@ int snapraid_main(int argc, char* argv[])
} else if (operation == OPERATION_REHASH) {
state_read(&state);
/* intercept signals while operating */
signal_init();
state_rehash(&state);
/*
* Intercept signals while operating
*
* Intentionally do this after the touch operation.
*
* The signal protection is meant only for saving the content file,
* or an early stop of long operations.
*/
signal_init();
/* save the new state if required */
if (state.need_write)
state_write(&state);
@ -1945,10 +1952,18 @@ int snapraid_main(int argc, char* argv[])
state_touch(&state);
/* intercept signals while operating */
/*
* Intercept signals while operating
*
* Intentionally do this after the touch operation.
*
* The signal protection is meant only for saving the content file,
* or an early stop of long operations.
*/
signal_init();
state_write(&state);
if (state.need_write)
state_write(&state);
} else if (operation == OPERATION_SPINUP) {
ret = state_device(&state, DEVICE_UP, &filterlist_disk);
#if HAVE_CHECKER