mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-25 14:06:41 +01:00
Fix ZipToDirectory closing the input streams
This commit is contained in:
@@ -292,7 +292,15 @@ namespace Tgstation.Server.Host.IO
|
||||
if (zipFile == null)
|
||||
throw new ArgumentNullException(nameof(zipFile));
|
||||
|
||||
using var archive = new ZipArchive(zipFile, ZipArchiveMode.Read);
|
||||
#if NET7_0_OR_GREATER
|
||||
#warning Check if zip file seeking has been addressesed. See https://github.com/tgstation/tgstation-server/issues/1531
|
||||
#endif
|
||||
|
||||
// ZipArchive does a synchronous copy on unseekable streams we want to avoid
|
||||
if (!zipFile.CanSeek)
|
||||
throw new ArgumentException("Stream does not support seeking!", nameof(zipFile));
|
||||
|
||||
using var archive = new ZipArchive(zipFile, ZipArchiveMode.Read, true);
|
||||
archive.ExtractToDirectory(path);
|
||||
},
|
||||
cancellationToken,
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace Tgstation.Server.Host.IO
|
||||
/// Extract a set of <paramref name="zipFile"/> to a given <paramref name="path"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to unzip to.</param>
|
||||
/// <param name="zipFile">The <see cref="Stream"/> of the <see cref="global::System.IO.Compression.ZipArchive"/>.</param>
|
||||
/// <param name="zipFile">The <see cref="Stream"/> of the <see cref="global::System.IO.Compression.ZipArchive"/>. Must have <see cref="Stream.CanSeek"/> set to <see langword="true"/>. Will be read completely and left open. <see cref="Stream.Position"/> will be indeterminate.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation.</returns>
|
||||
Task ZipToDirectory(string path, Stream zipFile, CancellationToken cancellationToken);
|
||||
|
||||
Reference in New Issue
Block a user