Skip to content

Commit

Permalink
Corrects downloader crashing when file has no chunks specified
Browse files Browse the repository at this point in the history
  • Loading branch information
Inumedia committed Nov 1, 2017
1 parent 3c43fed commit e9d4295
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions NXLDownloader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public static void Download(Manifest manifest, Product selected, string selected
long toDownload = manifest.TotalUncompressedSize;
long downloaded = 0;

foreach (KeyValuePair<string, FileEntry> file in FileNames.Where(c => !directories.Contains(c)))
foreach (KeyValuePair<string, FileEntry> file in FileNames.Where(c => !directories.Contains(c) && c.Value.ChunkHashes.Count > 0))
{
string filePath = Path.Combine(output, file.Key);
Log($"Starting download of {file.Key}");
Expand Down Expand Up @@ -337,7 +337,7 @@ public static void Download(Manifest manifest, Product selected, string selected

if (writtenSize != file.Value.FileSize)
Log($"ERROR, mismatch written and expected size");
if (file.Value.FileSize != existingFileSize)
if (file.Value.FileSize != existingFileSize && file.Value.FileSize != writtenSize)
{
Log($"Existing file size does not match expected size, trimming to {file.Value.FileSize}");
using (FileStream fileOut = File.OpenWrite(filePath)) // Ensure no trailing excess data
Expand Down

0 comments on commit e9d4295

Please sign in to comment.