updatectl: Show a helpful error if an update is partially downloaded
If an update is partially downloaded and the user tries to update again, `updatectl` can’t currently do anything (it doesn’t yet support resuming downloads). At the moment, though, it’ll return success as if the system was up to date, even though it isn’t up to date. Instead, print a more helpful error message telling the user to try vacuuming the partial version and trying again. I decided not to make it automatically vacuum the partial version, as that seems like a way to get into a nasty retry loop if, for example, the checksum provided by the server doesn’t match that of the downloaded file (which is one way to trigger this code path). Add an integration test which simulates this failure by corrupting the `SHA256SUMS` file, trying to download an update, and then working through the recovery steps. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Fixes: https://github.com/systemd/systemd/issues/41502
This commit is contained in:
@@ -1029,9 +1029,7 @@ static int context_acquire(
|
||||
if (FLAGS_SET(us->flags, UPDATE_INCOMPLETE))
|
||||
log_info("Selected update '%s' is already installed, but incomplete. Repairing.", us->version);
|
||||
else if (FLAGS_SET(us->flags, UPDATE_PARTIAL)) {
|
||||
log_info("Selected update '%s' is already acquired and partially installed. Vacuum it to try installing again.", us->version);
|
||||
|
||||
return 0;
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EUCLEAN), "Selected update '%s' is already acquired and partially installed. Vacuum it to try installing again.", us->version);
|
||||
} else if (FLAGS_SET(us->flags, UPDATE_PENDING)) {
|
||||
log_info("Selected update '%s' is already acquired and pending installation.", us->version);
|
||||
|
||||
|
||||
@@ -867,6 +867,10 @@ static int update_render_progress(sd_event_source *source, void *userdata) {
|
||||
clear_progress_bar_unbuffered(target);
|
||||
fprintf(stderr, "%s: %s Already up-to-date\n", target, GREEN_CHECK_MARK());
|
||||
n--; /* Don't consider this target in the total */
|
||||
} else if (progress == -EUCLEAN) {
|
||||
clear_progress_bar_unbuffered(target);
|
||||
fprintf(stderr, "%s: %s Update is already acquired and partially installed. Vacuum it to try installing again.\n", target, RED_CROSS_MARK());
|
||||
total += 100;
|
||||
} else if (progress < 0) {
|
||||
clear_progress_bar_unbuffered(target);
|
||||
fprintf(stderr, "%s: %s %s\n", target, RED_CROSS_MARK(), STRERROR(progress));
|
||||
|
||||
Reference in New Issue
Block a user