Skip to content

Commit 39e20dc

Browse files
authored
Merge pull request #8951 from danmoseley/fixcopycancel
Fix copy cancelation
2 parents 021b81b + 92f3600 commit 39e20dc

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/Tasks/Copy.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,18 @@ internal bool Execute(
422422

423423
// Use single-threaded code path when requested or when there is only copy to make
424424
// (no need to create all the parallel infrastructure for that case).
425-
bool success = parallelism == 1 || DestinationFiles.Length == 1
426-
? CopySingleThreaded(copyFile, out destinationFilesSuccessfullyCopied)
427-
: CopyParallel(copyFile, parallelism, out destinationFilesSuccessfullyCopied);
425+
bool success = false;
426+
427+
try
428+
{
429+
success = parallelism == 1 || DestinationFiles.Length == 1
430+
? CopySingleThreaded(copyFile, out destinationFilesSuccessfullyCopied)
431+
: CopyParallel(copyFile, parallelism, out destinationFilesSuccessfullyCopied);
432+
}
433+
catch (OperationCanceledException)
434+
{
435+
return false;
436+
}
428437

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

0 commit comments

Comments
 (0)