Always write to temp file if compressing after

This commit is contained in:
Matt Nadareski
2024-07-16 15:14:59 -04:00
parent 41d8b4297e
commit b9817c9af5
3 changed files with 11 additions and 5 deletions

View File

@@ -328,7 +328,9 @@ namespace SabreTools.FileTypes.Archives
usableDate = dt;
// Copy the input stream to the output
inputStream.Seek(0, SeekOrigin.Begin);
if (inputStream.CanSeek)
inputStream.Seek(0, SeekOrigin.Begin);
tarFile.AddEntry(baseFile.Filename, inputStream, size: baseFile.Size ?? 0, modified: usableDate);
}
@@ -384,7 +386,9 @@ namespace SabreTools.FileTypes.Archives
if (index < 0)
{
// Copy the input file to the output
inputStream.Seek(0, SeekOrigin.Begin);
if (inputStream.CanSeek)
inputStream.Seek(0, SeekOrigin.Begin);
tarFile.AddEntry(baseFile.Filename, inputStream, size: baseFile.Size ?? 0, modified: usableDate);
}

View File

@@ -428,7 +428,9 @@ namespace SabreTools.FileTypes.Archives
// If the archive doesn't exist, create it and put the single file
if (!File.Exists(archiveFileName))
{
inputStream.Seek(0, SeekOrigin.Begin);
if (inputStream.CanSeek)
inputStream.Seek(0, SeekOrigin.Begin);
zipReturn = zipFile.ZipFileCreate(tempFile);
// Open the input file for reading