修复Gzip解压报错文件找不到问题 (#465)

This commit is contained in:
nilaoda 2024-10-20 12:39:04 +08:00 committed by GitHub
parent 584d3c892b
commit 2bf4f29f28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 7 deletions

View File

@ -143,15 +143,13 @@ namespace N_m3u8DL_RE.Util
/// <param name="filePath"></param>
public static async Task DeGzipFileAsync(string filePath)
{
string deGzipFile = Path.ChangeExtension(filePath, ".tmp");
var deGzipFile = Path.ChangeExtension(filePath, ".dezip_tmp");
try
{
using (var fileToDecompressAsStream = File.OpenRead(filePath))
{
using var decompressedStream = File.Create(deGzipFile);
using var decompressionStream = new GZipStream(fileToDecompressAsStream, CompressionMode.Decompress);
await decompressionStream.CopyToAsync(decompressedStream);
}
await using var fileToDecompressAsStream = File.OpenRead(filePath);
await using var decompressedStream = File.Create(deGzipFile);
await using var decompressionStream = new GZipStream(fileToDecompressAsStream, CompressionMode.Decompress);
await decompressionStream.CopyToAsync(decompressedStream);
File.Delete(filePath);
File.Move(deGzipFile, filePath);
}