Skip to content

Commit a800bf6

Browse files
authored
Fix handling of fw version (#133)
1 parent 6332868 commit a800bf6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

nanoFirmwareFlasher/FirmwarePackage.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ internal abstract class FirmwarePackage : IDisposable
2828
private const string _communityTargetsRepo = "nanoframework-images-community-targets";
2929

3030
private readonly string _targetName;
31-
private string _fwVersion;
3231
private readonly bool _preview;
3332

3433
private const string _readmeContent = "This folder contains nanoFramework firmware files. Can safely be removed.";
@@ -76,7 +75,7 @@ protected FirmwarePackage(
7675
bool preview)
7776
{
7877
_targetName = targetName;
79-
_fwVersion = fwVersion;
78+
Version = fwVersion;
8079
_preview = preview;
8180
}
8281

@@ -214,7 +213,7 @@ protected async Task<ExitCodes> DownloadAndExtractAsync()
214213
// try to get download URL
215214
DownloadUrlResult downloadResult = await GetDownloadUrlAsync(
216215
_targetName,
217-
_fwVersion,
216+
Version,
218217
_preview,
219218
Verbosity);
220219

@@ -224,6 +223,8 @@ protected async Task<ExitCodes> DownloadAndExtractAsync()
224223
}
225224

226225
downloadUrl = downloadResult.Url;
226+
227+
// update with version from package about to be downloaded
227228
Version = downloadResult.Version;
228229

229230
stepSuccessful = !string.IsNullOrEmpty(downloadUrl);
@@ -247,7 +248,7 @@ protected async Task<ExitCodes> DownloadAndExtractAsync()
247248
// reset flag
248249
stepSuccessful = false;
249250

250-
fwFileName = $"{_targetName}-{_fwVersion}.zip";
251+
fwFileName = $"{_targetName}-{Version}.zip";
251252

252253
// check if we already have the file
253254
if (!File.Exists(
@@ -308,13 +309,13 @@ protected async Task<ExitCodes> DownloadAndExtractAsync()
308309

309310
if (fwFiles.Any())
310311
{
311-
if (string.IsNullOrEmpty(_fwVersion))
312+
if (string.IsNullOrEmpty(Version))
312313
{// take the 1st one
313314
fwFileName = fwFiles.First().FullName;
314315
}
315316
else
316317
{
317-
string targetFileName = $"{_targetName}-{_fwVersion}.zip";
318+
string targetFileName = $"{_targetName}-{Version}.zip";
318319
fwFileName = fwFiles.Where(w => w.Name == targetFileName).Select(s => s.FullName).FirstOrDefault();
319320
}
320321

0 commit comments

Comments
 (0)