Skip to content

Commit

Permalink
Fix the asset check code
Browse files Browse the repository at this point in the history
  • Loading branch information
monkbroc committed Apr 15, 2024
1 parent 79046f7 commit 70babcd
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/lib/flash-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ async function _flashDeviceInNormalMode(device, data, { name, progress, checkSki
}
return device;
}
try {
await device.enterListeningMode();
await delay(1000); // Just in case
} catch (error) {
// ignore
}
await device.updateFirmware(data, { progress, timeout: FLASH_TIMEOUT });
return device;
} catch (error) {
Expand All @@ -90,12 +96,6 @@ async function prepareDeviceForFlash({ device, mode, progress }) {
}
device = await usbUtils.reopenInNormalMode(device, { reset: true });
}
try {
await device.enterListeningMode();
await delay(1000); // Just in case
} catch (error) {
// ignore
}
break;
case 'dfu':
if (!device.isInDfuMode) {
Expand Down Expand Up @@ -332,8 +332,9 @@ async function createFlashSteps({ modules, isInDfuMode, factory, platformId }) {
}

function _skipAsset(module, existingAssets) {
const name = path.basename(module.filename);
const hashAssetToBeFlashed = _get256Hash(module);
return existingAssets.some((asset) => hashAssetToBeFlashed === asset.hash && module.filename === asset.name);
return existingAssets.some((asset) => hashAssetToBeFlashed === asset.hash && name === asset.name);
}

function _get256Hash(module) {
Expand Down

0 comments on commit 70babcd

Please sign in to comment.