Skip to content

Commit

Permalink
Fix fwversion parameter not pulling the correct file (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
alberk8 authored May 10, 2021
1 parent 8ebe00d commit 49d50a6
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions nanoFirmwareFlasher/FirmwarePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ protected async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync()

// reference targets
var repoName = _stable ? _refTargetsStableRepo : _refTargetsDevRepo;
string requestUri = $"{_cloudsmithPackages}/{repoName}/?page=1&query={_targetName} latest";
// get the firmware version if it is defined
var fwVersion = string.IsNullOrEmpty(_fwVersion) ? "latest" : _fwVersion;
string requestUri = $"{_cloudsmithPackages}/{repoName}/?page=1&query={_targetName} {fwVersion}";

string downloadUrl = string.Empty;

Expand Down Expand Up @@ -157,7 +159,8 @@ protected async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync()
}

// try with community targets
requestUri = $"{_cloudsmithPackages}/{_communityTargetsepo}/?page=1&query={_targetName} latest";

requestUri = $"{_cloudsmithPackages}/{_communityTargetsepo}/?page=1&query={_targetName} {fwVersion}";
repoName = _communityTargetsepo;

response = await _cloudsmithClient.GetAsync(requestUri);
Expand Down Expand Up @@ -186,10 +189,24 @@ protected async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync()
if (string.IsNullOrEmpty(_fwVersion))
{
_fwVersion = packageInfo.ElementAt(0).Version;
// grab download URL
downloadUrl = packageInfo.ElementAt(0).DownloadUrl;
}
else
{
//get the download Url from the Cloudsmith Package info
// addition check if the cloudsmith json return empty json
if(packageInfo is null || packageInfo.Count == 0)
{
return ExitCodes.E9005;
}
else
{
downloadUrl = packageInfo.Where(w => w.Version == _fwVersion).Select(s => s.DownloadUrl).FirstOrDefault();
}
}

// grab download URL
downloadUrl = packageInfo.ElementAt(0).DownloadUrl;


// set exposed property
Version = _fwVersion;
Expand Down

0 comments on commit 49d50a6

Please sign in to comment.