Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions RecursiveExtractor/Extractors/TarExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, Extra
catch (Exception e)
{
Logger.Debug(Extractor.FAILED_PARSING_ERROR_MESSAGE_STRING, ArchiveFileType.TAR, fileEntry.FullPath, tarEntry.Key, e.GetType());
fs?.Dispose();
continue;
}
var name = tarEntry.Key?.Replace('/', Path.DirectorySeparatorChar);
if (string.IsNullOrEmpty(name))
Expand Down Expand Up @@ -132,6 +134,8 @@ public IEnumerable<FileEntry> Extract(FileEntry fileEntry, ExtractorOptions opti
catch (Exception e)
{
Logger.Debug(Extractor.FAILED_PARSING_ERROR_MESSAGE_STRING, ArchiveFileType.TAR, fileEntry.FullPath, tarEntry.Key, e.GetType());
fs?.Dispose();
continue;
}
var name = tarEntry.Key?.Replace('/', Path.DirectorySeparatorChar);
if (string.IsNullOrEmpty(name))
Expand Down
9 changes: 6 additions & 3 deletions RecursiveExtractor/Extractors/ZipExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@ public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, Extra
catch (Exception e)
{
Logger.Debug(Extractor.FAILED_PARSING_ERROR_MESSAGE_STRING, ArchiveFileType.ZIP, fileEntry.FullPath, zipEntry.Key, e.GetType());
target?.Dispose();
continue;
}

target ??= new MemoryStream();
var name = zipEntry.Key?.Replace('/', Path.DirectorySeparatorChar) ?? "";
var newFileEntry = new FileEntry(name, target, fileEntry, modifyTime: zipEntry.LastModifiedTime, memoryStreamCutoff: options.MemoryStreamCutoff);
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The async method should also use passthroughStream: true parameter when creating the FileEntry, consistent with the sync method and the TarExtractor pattern. Since the backing stream is already populated via CopyToAsync, setting this parameter avoids unnecessary stream re-copying in the FileEntry constructor, improving performance and reducing allocations.

Suggested change
var newFileEntry = new FileEntry(name, target, fileEntry, modifyTime: zipEntry.LastModifiedTime, memoryStreamCutoff: options.MemoryStreamCutoff);
var newFileEntry = new FileEntry(name, target, fileEntry, modifyTime: zipEntry.LastModifiedTime, memoryStreamCutoff: options.MemoryStreamCutoff, passthroughStream: true);

Copilot uses AI. Check for mistakes.

Expand Down Expand Up @@ -222,7 +223,7 @@ public IEnumerable<FileEntry> Extract(FileEntry fileEntry, ExtractorOptions opti
{
governor.CheckResourceGovernor(zipEntry.Size);

using var fs = StreamFactory.GenerateAppropriateBackingStream(options, zipEntry.Size);
var fs = StreamFactory.GenerateAppropriateBackingStream(options, zipEntry.Size);

try
{
Expand All @@ -232,10 +233,12 @@ public IEnumerable<FileEntry> Extract(FileEntry fileEntry, ExtractorOptions opti
catch (Exception e)
{
Logger.Debug(Extractor.FAILED_PARSING_ERROR_MESSAGE_STRING, ArchiveFileType.ZIP, fileEntry.FullPath, zipEntry.Key, e.GetType());
fs?.Dispose();
continue;
}

var name = zipEntry.Key?.Replace('/', Path.DirectorySeparatorChar) ?? "";
var newFileEntry = new FileEntry(name, fs, fileEntry, modifyTime: zipEntry.LastModifiedTime, memoryStreamCutoff: options.MemoryStreamCutoff);
var newFileEntry = new FileEntry(name, fs, fileEntry, passthroughStream: true, modifyTime: zipEntry.LastModifiedTime, memoryStreamCutoff: options.MemoryStreamCutoff);

if (options.Recurse || topLevel)
{
Expand Down
Loading