Wait for device reboot when using fwupdtool detach

This commit is contained in:
Richard Hughes 2021-11-05 10:28:33 +00:00
parent a346c582cc
commit 448772b73e

View File

@ -26,6 +26,7 @@
#include "fu-cabinet.h" #include "fu-cabinet.h"
#include "fu-context-private.h" #include "fu-context-private.h"
#include "fu-debug.h" #include "fu-debug.h"
#include "fu-device-list.h"
#include "fu-device-private.h" #include "fu-device-private.h"
#include "fu-engine.h" #include "fu-engine.h"
#include "fu-history.h" #include "fu-history.h"
@ -1521,6 +1522,7 @@ static gboolean
fu_util_detach(FuUtilPrivate *priv, gchar **values, GError **error) fu_util_detach(FuUtilPrivate *priv, gchar **values, GError **error)
{ {
g_autoptr(FuDevice) device = NULL; g_autoptr(FuDevice) device = NULL;
g_autoptr(FuDeviceList) device_list = fu_device_list_new();
g_autoptr(FuDeviceLocker) locker = NULL; g_autoptr(FuDeviceLocker) locker = NULL;
/* load engine */ /* load engine */
@ -1545,7 +1547,18 @@ fu_util_detach(FuUtilPrivate *priv, gchar **values, GError **error)
locker = fu_device_locker_new(device, error); locker = fu_device_locker_new(device, error);
if (locker == NULL) if (locker == NULL)
return FALSE; return FALSE;
return fu_device_detach_full(device, priv->progress, error); fu_device_list_add(device_list, device);
if (!fu_device_detach_full(device, priv->progress, error))
return FALSE;
/* wait for replug */
if (!priv->no_safety_check) {
if (!fu_device_list_wait_for_replug(device_list, error))
return FALSE;
}
/* success */
return TRUE;
} }
static gboolean static gboolean
@ -1618,6 +1631,7 @@ static gboolean
fu_util_attach(FuUtilPrivate *priv, gchar **values, GError **error) fu_util_attach(FuUtilPrivate *priv, gchar **values, GError **error)
{ {
g_autoptr(FuDevice) device = NULL; g_autoptr(FuDevice) device = NULL;
g_autoptr(FuDeviceList) device_list = fu_device_list_new();
g_autoptr(FuDeviceLocker) locker = NULL; g_autoptr(FuDeviceLocker) locker = NULL;
/* load engine */ /* load engine */
@ -1642,7 +1656,18 @@ fu_util_attach(FuUtilPrivate *priv, gchar **values, GError **error)
locker = fu_device_locker_new(device, error); locker = fu_device_locker_new(device, error);
if (locker == NULL) if (locker == NULL)
return FALSE; return FALSE;
return fu_device_attach_full(device, priv->progress, error); fu_device_list_add(device_list, device);
if (!fu_device_attach_full(device, priv->progress, error))
return FALSE;
/* wait for replug */
if (!priv->no_safety_check) {
if (!fu_device_list_wait_for_replug(device_list, error))
return FALSE;
}
/* success */
return TRUE;
} }
static gboolean static gboolean