Skip to content

Commit

Permalink
Fix buildkey 404 (betaflight#3899)
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis authored and chmelevskij committed Apr 27, 2024
1 parent 765d21b commit 3190435
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/js/tabs/firmware_flasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,12 @@ firmware_flasher.initialize = function (callback) {

self.buildApi.loadTarget(target, release, onTargetDetail);

if (self.validateBuildKey() && navigator.onLine) {
self.buildApi.loadOptionsByBuildKey(release, self.cloudBuildKey, buildOptions);
const OnInvalidBuildKey = () => self.buildApi.loadOptions(release, buildOptions);

if (self.validateBuildKey()) {
self.buildApi.loadOptionsByBuildKey(release, self.cloudBuildKey, buildOptions, OnInvalidBuildKey);
} else {
self.buildApi.loadOptions(release, buildOptions);
OnInvalidBuildKey();
}
}

Expand Down Expand Up @@ -1233,7 +1235,7 @@ firmware_flasher.updateDetectBoardButton = function() {
};

firmware_flasher.validateBuildKey = function() {
return this.cloudBuildKey?.length === 32;
return this.cloudBuildKey?.length === 32 && navigator.onLine;
};

/**
Expand Down Expand Up @@ -1319,7 +1321,7 @@ firmware_flasher.verifyBoard = function() {
}

function getBuildInfo() {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) && navigator.onLine && FC.CONFIG.flightControllerIdentifier === 'BTFL') {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) && FC.CONFIG.flightControllerIdentifier === 'BTFL') {
MSP.send_message(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.BUILD_KEY), false, () => {
MSP.send_message(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.CRAFT_NAME), false, () => {
// store FC.CONFIG.buildKey as the object gets destroyed after disconnect
Expand Down

0 comments on commit 3190435

Please sign in to comment.