Skip to content

Commit b85abeb

Browse files
authored
Remove the 4 hour Delay to download new Firmware (#80)
***NO_CI***
1 parent 62cc30c commit b85abeb

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

nanoFirmwareFlasher/FirmwarePackage.cs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,7 @@ protected async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync()
144144
.ToList();
145145
}
146146

147-
if (fwFiles.Any())
148-
{
149-
// get file creation date (from the 1st one)
150-
if ((DateTime.UtcNow - File.GetLastWriteTimeUtc(fwFiles.First().FullName)).TotalHours < 4)
151-
{
152-
// fw package has less than 4 hours
153-
// skip download
154-
skipDownload = true;
155-
}
156-
}
157-
147+
158148
if (!skipDownload)
159149
{
160150
// try to perform request
@@ -321,8 +311,20 @@ protected async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync()
321311

322312
if (fwFiles.Any())
323313
{
324-
// take the 1st one
325-
fwFileName = fwFiles.First().FullName;
314+
if (string.IsNullOrEmpty(_fwVersion))
315+
{// take the 1st one
316+
fwFileName = fwFiles.First().FullName;
317+
}
318+
else
319+
{
320+
string targetFileName = $"{_targetName}-{_fwVersion}.zip";
321+
fwFileName = fwFiles.Where(w => w.Name == targetFileName).Select(s => s.FullName).FirstOrDefault();
322+
}
323+
324+
if (string.IsNullOrEmpty(fwFileName))
325+
{
326+
return ExitCodes.E9007;
327+
}
326328

327329
// get the version form the file name
328330
var pattern = @"(\d+\.\d+\.\d+)(\.\d+|-.+)(?=\.zip)";

0 commit comments

Comments
 (0)