From 7e070c9bd7996ccfe51285aa4782218f19145ef6 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 12 Jan 2018 16:50:05 +0000 Subject: [PATCH] Record an error if any NEEDS_REBOOT transaction fails to be applied In the case of failing to even set up UpdateCapsule, the uefi plugin would dutifully return SUCCESS as it was referring to the 2nd-to-last update that actually worked. --- src/fu-engine.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/fu-engine.c b/src/fu-engine.c index 151f2c9c2..bac4cbd58 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -3368,23 +3368,28 @@ fu_engine_update_history_device (FuEngine *self, FuDevice *dev_history, GError * return TRUE; } - /* find the plugin that started the update */ + /* does the plugin know the update failure */ plugin = fu_plugin_list_find_by_name (self->plugin_list, fu_device_get_plugin (dev), error); if (plugin == NULL) return FALSE; - - /* the plugin knows the update state */ if (!fu_plugin_runner_get_results (plugin, dev, error)) return FALSE; - if (fu_device_get_update_state (dev) != FWUPD_UPDATE_STATE_NEEDS_REBOOT) { - if (!fu_history_set_device_error (self->history, - fu_device_get_id (dev), - fu_device_get_update_error (dev), - error)) - return FALSE; + + /* the plugin either can't tell us the error, or doesn't know itself */ + if (fu_device_get_update_state (dev) != FWUPD_UPDATE_STATE_FAILED) { + g_debug ("falling back to generic failure"); + fu_device_set_update_error (dev, "failed to run update on reboot"); } + + /* update the state in the database */ + if (!fu_history_set_device_error (self->history, fu_device_get_id (dev), + fu_device_get_update_error (dev), + error)) + return FALSE; + + /* success */ return TRUE; }