Skip to content

Commit

Permalink
Merge pull request #8951 from danmoseley/fixcopycancel
Browse files Browse the repository at this point in the history
Fix copy cancelation
  • Loading branch information
JanKrivanek authored Jun 30, 2023
2 parents 021b81b + 92f3600 commit 39e20dc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Tasks/Copy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,18 @@ internal bool Execute(

// Use single-threaded code path when requested or when there is only copy to make
// (no need to create all the parallel infrastructure for that case).
bool success = parallelism == 1 || DestinationFiles.Length == 1
? CopySingleThreaded(copyFile, out destinationFilesSuccessfullyCopied)
: CopyParallel(copyFile, parallelism, out destinationFilesSuccessfullyCopied);
bool success = false;

try
{
success = parallelism == 1 || DestinationFiles.Length == 1
? CopySingleThreaded(copyFile, out destinationFilesSuccessfullyCopied)
: CopyParallel(copyFile, parallelism, out destinationFilesSuccessfullyCopied);
}
catch (OperationCanceledException)
{
return false;
}

// copiedFiles contains only the copies that were successful.
CopiedFiles = destinationFilesSuccessfullyCopied.ToArray();
Expand Down

0 comments on commit 39e20dc

Please sign in to comment.