mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Always write to temp file if compressing after
This commit is contained in:
@@ -425,9 +425,9 @@ namespace SabreTools.DatTools
|
||||
if (RebuildTorrentXz(datFile, datItem, file, outDir, outputFormat, isZip))
|
||||
return true;
|
||||
|
||||
// If there is more than one dupe, write to a temporary file and use that stream instead
|
||||
// Create a temp file if we're compressing the data after
|
||||
string? tempFile = null;
|
||||
if (dupes.Count > 1)
|
||||
if (outputFormat != OutputFormat.Folder)
|
||||
{
|
||||
tempFile = Path.Combine(outDir, $"tmp{System.Guid.NewGuid()}");
|
||||
Stream tempStream = System.IO.File.Open(tempFile, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user