mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-23 15:34:34 +00:00
rar byte[] better
This commit is contained in:
@@ -48,6 +48,20 @@ public partial class RarArchive : AbstractArchive<RarArchiveEntry, RarVolume>, I
|
||||
}
|
||||
}
|
||||
|
||||
public override async ValueTask DisposeAsync()
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
if (UnpackV1.IsValueCreated && UnpackV1.Value is IDisposable unpackV1)
|
||||
{
|
||||
unpackV1.Dispose();
|
||||
}
|
||||
|
||||
_disposed = true;
|
||||
await base.DisposeAsync();
|
||||
}
|
||||
}
|
||||
|
||||
protected override IEnumerable<RarArchiveEntry> LoadEntries(IEnumerable<RarVolume> volumes) =>
|
||||
RarArchiveEntryFactory.GetEntries(this, volumes, ReaderOptions);
|
||||
|
||||
|
||||
@@ -87,10 +87,10 @@ internal class RarStream : Stream, IStreamStack
|
||||
#endif
|
||||
ArrayPool<byte>.Shared.Return(this.tmpBuffer);
|
||||
this.tmpBuffer = null;
|
||||
readStream.Dispose();
|
||||
}
|
||||
isDisposed = true;
|
||||
base.Dispose(disposing);
|
||||
readStream.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,17 +126,13 @@ internal sealed partial class Unpack : BitInput, IRarUnpack
|
||||
|
||||
private FileHeader fileHeader;
|
||||
|
||||
private void Init(byte[] window)
|
||||
|
||||
private void Init()
|
||||
{
|
||||
if (this.window is null && window is null)
|
||||
if (this.window is null)
|
||||
{
|
||||
this.window = ArrayPool<byte>.Shared.Rent(PackDef.MAXWINSIZE);
|
||||
}
|
||||
else if (window is not null)
|
||||
{
|
||||
this.window = window;
|
||||
externalWindow = true;
|
||||
}
|
||||
inAddr = 0;
|
||||
UnpInitData(false);
|
||||
}
|
||||
@@ -149,7 +145,7 @@ internal sealed partial class Unpack : BitInput, IRarUnpack
|
||||
this.writeStream = writeStream;
|
||||
if (!fileHeader.IsSolid)
|
||||
{
|
||||
Init(null);
|
||||
Init();
|
||||
}
|
||||
suspended = false;
|
||||
DoUnpack();
|
||||
@@ -168,7 +164,7 @@ internal sealed partial class Unpack : BitInput, IRarUnpack
|
||||
this.writeStream = writeStream;
|
||||
if (!fileHeader.IsSolid)
|
||||
{
|
||||
Init(null);
|
||||
Init();
|
||||
}
|
||||
suspended = false;
|
||||
await DoUnpackAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
Reference in New Issue
Block a user