From e2b8a2797e3983cbd2cf5deebbdf6ee55924124d Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Sat, 9 Nov 2019 22:10:35 -0600 Subject: [PATCH] Skip cleanup after device is done updating if `will-disappear` is set (Fixes: #1529) This fixes a regression introduced by 2031ce3bf67885a4db247fa4088b36ae50011ca0 that leads to: ``` USB error on device 2dc8:5750 : No such device (it may have been disconnected) [-4] ``` --- plugins/ebitdo/fu-ebitdo-device.c | 10 ++++++++-- src/fu-engine.c | 9 ++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/ebitdo/fu-ebitdo-device.c b/plugins/ebitdo/fu-ebitdo-device.c index 385c2618f..4dd9941d4 100644 --- a/plugins/ebitdo/fu-ebitdo-device.c +++ b/plugins/ebitdo/fu-ebitdo-device.c @@ -512,8 +512,14 @@ fu_ebitdo_device_write_firmware (FuDevice *device, /* when doing a soft-reboot the device does not re-enumerate properly * so manually reboot the GUsbDevice */ fu_device_set_status (device, FWUPD_STATUS_DEVICE_RESTART); - if (!g_usb_device_reset (usb_device, error)) { - g_prefix_error (error, "failed to force-reset device: "); + if (!g_usb_device_reset (usb_device, &error_local)) { + g_prefix_error (&error_local, "failed to force-reset device: "); + if (fu_device_has_flag (device, FWUPD_DEVICE_FLAG_WILL_DISAPPEAR)) { + fu_device_set_remove_delay (device, 0); + g_debug ("%s", error_local->message); + return TRUE; + } + g_propagate_error (error, g_steal_pointer (&error_local)); return FALSE; } diff --git a/src/fu-engine.c b/src/fu-engine.c index 9c12f8cd7..1c348010d 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -1872,7 +1872,14 @@ fu_engine_device_cleanup (FuEngine *self, FwupdInstallFlags flags, GError **error) { - g_autoptr(FuDeviceLocker) locker = fu_device_locker_new (device, error); + g_autoptr(FuDeviceLocker) locker = NULL; + + if (fu_device_has_flag (device, FWUPD_DEVICE_FLAG_WILL_DISAPPEAR)) { + g_debug ("skipping device cleanup due to will-disappear flag"); + return TRUE; + } + + locker = fu_device_locker_new (device, error); if (locker == NULL) return FALSE; return fu_device_cleanup (device, flags, error);