Skip to content
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 @@ -135,6 +137,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
11 changes: 7 additions & 4 deletions RecursiveExtractor/Extractors/ZipExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,12 @@ 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);
var newFileEntry = new FileEntry(name, target, fileEntry, modifyTime: zipEntry.LastModifiedTime, memoryStreamCutoff: options.MemoryStreamCutoff, passthroughStream: true);

try
{
Expand Down Expand Up @@ -254,7 +255,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 @@ -264,10 +265,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);

try
{
Expand Down
Loading