Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions nanoFirmwareFlasher/FirmwarePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,7 @@ protected async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync()
.ToList();
}

if (fwFiles.Any())
{
// get file creation date (from the 1st one)
if ((DateTime.UtcNow - File.GetLastWriteTimeUtc(fwFiles.First().FullName)).TotalHours < 4)
{
// fw package has less than 4 hours
// skip download
skipDownload = true;
}
}


if (!skipDownload)
{
// try to perform request
Expand Down Expand Up @@ -321,8 +311,20 @@ protected async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync()

if (fwFiles.Any())
{
// take the 1st one
fwFileName = fwFiles.First().FullName;
if (string.IsNullOrEmpty(_fwVersion))
{// take the 1st one
fwFileName = fwFiles.First().FullName;
}
else
{
string targetFileName = $"{_targetName}-{_fwVersion}.zip";
fwFileName = fwFiles.Where(w => w.Name == targetFileName).Select(s => s.FullName).FirstOrDefault();
}

if (string.IsNullOrEmpty(fwFileName))
{
return ExitCodes.E9007;
}

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