Improve and change the order of the user messages

The "Everything is OK" is now printed as latest one.
This commit is contained in:
Andrea Mazzoleni 2025-10-13 11:46:36 +02:00
parent 467fb8c1ac
commit 52ef48655f
7 changed files with 40 additions and 25 deletions

View file

@ -1834,7 +1834,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
}
end:
state_progress_end(state, countpos, countmax, countsize);
state_progress_end(state, countpos, countmax, countsize, "Nothing to check.\n");
bail:
/* close all the files left open */

View file

@ -363,7 +363,7 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
}
end:
state_progress_end(state, countpos, countmax, countsize);
state_progress_end(state, countpos, countmax, countsize, "Nothing to dry.\n");
state_usage_print(state);

View file

@ -665,7 +665,11 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
}
end:
state_progress_end(state, countpos, countmax, countsize);
state_progress_end(state, countpos, countmax, countsize, "Nothing to scrub. Use the -p PLAN option to select a different plan, like -p full.\n");
/* save the new state if required */
if (state->need_write || state->opt.force_content_write)
state_write(state);
state_usage_print(state);
@ -788,10 +792,13 @@ int state_scrub(struct snapraid_state* state, int plan, int olderthan)
ps.plan = SCRUB_EVEN;
} else if (plan == SCRUB_FULL) {
ps.plan = SCRUB_FULL;
msg_info("Scrub plan: full. All data blocks will be checked.\n");
} else if (plan == SCRUB_NEW) {
ps.plan = SCRUB_NEW;
msg_info("Scrub plan: new. Only blocks that have never been scrubbed will be checked.\n");
} else if (plan == SCRUB_BAD) {
ps.plan = SCRUB_BAD;
msg_info("Scrub plan: bad. Only blocks previously marked as bad will be checked.\n");
} else if (state->opt.force_scrub_at) {
/* scrub the specified amount of blocks */
ps.plan = SCRUB_AUTO;
@ -812,6 +819,18 @@ int state_scrub(struct snapraid_state* state, int plan, int olderthan)
/* by default use a 10 day time limit */
recentlimit = now - 10 * 24 * 3600;
}
if (plan >= 0) {
if (olderthan >= 0)
msg_info("Scrub plan: auto. %d%% of the array, older than %d days, will be checked.\n", plan, olderthan);
else
msg_info("Scrub plan: auto. %d%% of the array, older than 10 days, will be checked.\n", plan);
} else {
if (olderthan >= 0)
msg_info("Scrub plan: auto. 8.3%% of the array, older than %d days, will be checked.\n", olderthan);
else
msg_info("Scrub plan: auto. 8.3%% of the array, older than 10 days, will be checked.\n");
}
}
/* identify the time limit */

View file

@ -1420,14 +1420,6 @@ int snapraid_main(int argc, char* argv[])
ret = state_sync(&state, blockstart, blockcount);
/* save the new state if required */
if (!opt.kill_after_sync) {
if ((state.need_write || state.opt.force_content_write))
state_write(&state);
} else {
log_fatal("WARNING! Skipped writing state due to --test-kill-after-sync option.\n");
}
/* abort if required */
if (ret != 0) {
/* LCOV_EXCL_START */
@ -1468,10 +1460,6 @@ int snapraid_main(int argc, char* argv[])
ret = state_scrub(&state, plan, olderthan);
/* save the new state if required */
if (state.need_write || state.opt.force_content_write)
state_write(&state);
/* abort if required */
if (ret != 0) {
/* LCOV_EXCL_START */
@ -1494,14 +1482,14 @@ int snapraid_main(int argc, char* argv[])
} else if (operation == OPERATION_TOUCH) {
state_read(&state);
memory();
state_touch(&state);
/* intercept signals while operating */
signal_init();
state_write(&state);
memory();
} else if (operation == OPERATION_SPINUP) {
state_device(&state, DEVICE_UP, &filterlist_disk);
} else if (operation == OPERATION_SPINDOWN) {

View file

@ -4376,7 +4376,7 @@ int state_progress_begin(struct snapraid_state* state, block_off_t blockstart, b
return 1;
}
void state_progress_end(struct snapraid_state* state, block_off_t countpos, block_off_t countmax, data_off_t countsize)
void state_progress_end(struct snapraid_state* state, block_off_t countpos, block_off_t countmax, data_off_t countsize, const char* msg)
{
if (state->opt.gui) {
log_tag("run:end\n");
@ -4385,7 +4385,7 @@ void state_progress_end(struct snapraid_state* state, block_off_t countpos, bloc
if (state->need_write || state->written) {
msg_status("100%% completed\n");
} else {
msg_status("Nothing to do\n");
msg_status("%s", msg);
}
} else {
time_t now;

View file

@ -327,7 +327,7 @@ int state_progress_begin(struct snapraid_state* state, block_off_t blockstart, b
/**
* End the progress visualization.
*/
void state_progress_end(struct snapraid_state* state, block_off_t countpos, block_off_t countmax, data_off_t countsize);
void state_progress_end(struct snapraid_state* state, block_off_t countpos, block_off_t countmax, data_off_t countsize, const char* msg);
/**
* Write the progress.

View file

@ -341,7 +341,7 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
}
end:
state_progress_end(state, countpos, countmax, countsize);
state_progress_end(state, countpos, countmax, countsize, "Nothing to hash.\n");
/* note that at this point no io_error is possible */
/* because at the first one we bail out */
@ -1361,9 +1361,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
}
end:
state_progress_end(state, countpos, countmax, countsize);
state_usage_print(state);
state_progress_end(state, countpos, countmax, countsize, "Nothing to sync.\n");
/* before returning we ensure that */
/* the parity is really written flushing the disk cache */
@ -1376,6 +1374,16 @@ end:
/* LCOV_EXCL_STOP */
}
/* save the new state if required */
if (!state->opt.kill_after_sync) {
if ((state->need_write || state->opt.force_content_write))
state_write(state);
} else {
log_fatal("WARNING! Skipped writing state due to --test-kill-after-sync option.\n");
}
state_usage_print(state);
if (error || silent_error || io_error) {
msg_status("\n");
msg_status("%8u file errors\n", error);
@ -1607,7 +1615,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
/* LCOV_EXCL_STOP */
}
} else {
msg_status("Nothing to do\n");
msg_status("Nothing to sync.\n");
}
}