Skip to content

Commit cab7ab3

Browse files
committed
Clean up after extraction cancellation
Correctly clean up half extracted files if a cancellation is requested during `ExtractFileSet`.
1 parent d6ad016 commit cab7ab3

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

CabinetManager/core/CfCabinet.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,14 @@ void Progress(CfSaveEventArgs args) {
322322
args.TotalBytesDone = totalNumberOfBytesDone;
323323
OnProgress?.Invoke(this, args);
324324
}
325-
326-
fileToExtract.Parent.ExtractFileFromDataBlocks(_reader, relativePathInCab, extractionPath, _cancelToken, Progress);
325+
326+
try {
327+
fileToExtract.Parent.ExtractFileFromDataBlocks(_reader, relativePathInCab, extractionPath, _cancelToken, Progress);
328+
} finally {
329+
if (File.Exists(extractionPath)) {
330+
File.Delete(extractionPath);
331+
}
332+
}
327333

328334
File.SetCreationTime(extractionPath, fileToExtract.FileDateTime);
329335
File.SetLastWriteTime(extractionPath, fileToExtract.FileDateTime);

docs/RELEASE_NOTES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
## Improvements
22

3-
Added ICabManager.MoveFileSet to the API.
3+
- Correctly clean up half extracted files if a cancellation is requested during `ExtractFileSet`.
4+
-

0 commit comments

Comments
 (0)