mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-24 15:27:17 +00:00
fix(usbboot): handle LIBUSB_ERROR_NO_DEVICE when claiming a USB interface (#1796)
Consider the following scenario: - Usbboot runs successfully on a device - Before the block device gets a chance to appear, we run usbboot again If we're fast enough, usbboot will try to claim the device interface, but then the drive might not be there anymore, causing a `LIBUSB_ERROR_NO_DEVICE`. This commit addresses that scenario, and simply ignores the drive. Change-Type: patch Changelog-Entry: Fix `LIBUSB_ERROR_NO_DEVICE` error at the end of usbboot. Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This commit is contained in:
parent
39e6207183
commit
a11a22453a
@ -400,7 +400,17 @@ exports.scan = (options) => {
|
||||
|
||||
const deviceInterface = device.interface(addresses.interface)
|
||||
debug(`Claiming interface: ${addresses.interface}`)
|
||||
deviceInterface.claim()
|
||||
|
||||
try {
|
||||
deviceInterface.claim()
|
||||
} catch (error) {
|
||||
if (error.message === 'LIBUSB_ERROR_NO_DEVICE') {
|
||||
debug('Couldn\'t claim the interface. Assuming the device is gone')
|
||||
return null
|
||||
}
|
||||
|
||||
throw error
|
||||
}
|
||||
|
||||
const endpoint = deviceInterface.endpoint(addresses.endpoint)
|
||||
|
||||
@ -429,5 +439,5 @@ exports.scan = (options) => {
|
||||
// See http://bluebirdjs.com/docs/api/promise.map.html
|
||||
}, {
|
||||
concurrency: 5
|
||||
})
|
||||
}).then(_.compact)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user