fix disposal and other simple issues

This commit is contained in:
Adam Hathcock
2026-01-22 16:38:35 +00:00
parent c5814502f6
commit b622a2ce73
7 changed files with 15 additions and 8 deletions

View File

@@ -34,7 +34,7 @@ public partial class TarArchive
new SourceStream(
fileInfo,
i => ArchiveVolumeFactory.GetFilePart(i, fileInfo),
readerOptions ?? new ReaderOptions() { LeaveStreamOpen = false}
readerOptions ?? new ReaderOptions() { LeaveStreamOpen = false }
)
);
}
@@ -50,7 +50,7 @@ public partial class TarArchive
new SourceStream(
files[0],
i => i < files.Length ? files[i] : null,
readerOptions ?? new ReaderOptions() { LeaveStreamOpen = false}
readerOptions ?? new ReaderOptions() { LeaveStreamOpen = false }
)
);
}

View File

@@ -21,7 +21,7 @@ public partial class ZipArchive
public static IWritableArchive OpenArchive(string filePath, ReaderOptions? readerOptions = null)
{
filePath.NotNullOrEmpty(nameof(filePath));
return OpenArchive(new FileInfo(filePath), readerOptions ?? new ReaderOptions());
return OpenArchive(new FileInfo(filePath), readerOptions);
}
public static IWritableArchive OpenArchive(
@@ -35,6 +35,9 @@ public partial class ZipArchive
fileInfo,
i => ZipArchiveVolumeFactory.GetFilePart(i, fileInfo),
readerOptions ?? new ReaderOptions()
{
LeaveStreamOpen = false
}
)
);
}
@@ -51,6 +54,9 @@ public partial class ZipArchive
files[0],
i => i < files.Length ? files[i] : null,
readerOptions ?? new ReaderOptions()
{
LeaveStreamOpen = false
}
)
);
}
@@ -81,7 +87,7 @@ public partial class ZipArchive
}
return new ZipArchive(
new SourceStream(stream, i => null, readerOptions ?? new ReaderOptions())
new SourceStream(stream, i => null, readerOptions ?? new ReaderOptions())
);
}

View File

@@ -179,7 +179,7 @@ internal abstract partial class ZipFilePart
}
case ZipCompressionMethod.BZip2:
{
return BZip2Stream.Create(stream, CompressionMode.Decompress, false);
return await BZip2Stream.CreateAsync(stream, CompressionMode.Decompress, false, cancellationToken: cancellationToken);
}
case ZipCompressionMethod.LZMA:
{

View File

@@ -33,7 +33,7 @@ public abstract partial class AbstractWriter
await Task.CompletedTask.ConfigureAwait(false);
}
public ValueTask DisposeAsync()
public ValueTask DisposeAsync()
{
if (!_isDisposed)
{

View File

@@ -52,7 +52,7 @@ public partial class ZipWriter : AbstractWriter
protected override void Dispose(bool isDisposing)
{
if (isDisposing && OutputStream is not null)
if (isDisposing)
{
ulong size = 0;
foreach (var entry in entries)