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:
parent
bcadd6ff01
commit
4d631cc1b1
1 changed files with 6 additions and 5 deletions
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue