Update dest path & fix race reporting progress

Renaming destinationPath to destinationRelativePath for clarity.  This
string represents the path relative to the extract directory to which
files will be written.

We were missing an Interlocked.Increment during a parallel operation.
This commit is contained in:
Eric St. John 2016-06-10 12:35:32 -07:00 committed by Livar Cunha
parent bcadd6ff01
commit 4d631cc1b1

View file

@ -404,25 +404,26 @@ namespace Microsoft.DotNet.Archive
int filesAdded = 0;
sourceFiles.AsParallel().ForAll(sourceFile =>
{
string destinationPath = sourceFile.Substring(sourceDirectory.Length + 1);
// path relative to the destination/extracted directory to write the file
string destinationRelativePath = sourceFile.Substring(sourceDirectory.Length + 1);
if (destinationDirectory != null)
{
destinationPath = Path.Combine(destinationDirectory, destinationPath);
destinationRelativePath = Path.Combine(destinationDirectory, destinationRelativePath);
}
string extension = Path.GetExtension(sourceFile);
if (ZipExtensions.Any(ze => ze.Equals(extension, StringComparison.OrdinalIgnoreCase)))
{
AddZip(sourceFile, destinationPath);
AddZip(sourceFile, destinationRelativePath);
}
else
{
AddFile(sourceFile, destinationPath);
AddFile(sourceFile, destinationRelativePath);
}
progress.Report($"Adding {sourceDirectory}", ++filesAdded, sourceFiles.Length);
progress.Report($"Adding {sourceDirectory}", Interlocked.Increment(ref filesAdded), sourceFiles.Length);
});
}