优化文件存在判断

This commit is contained in:
nilaoda 2022-11-13 01:47:44 +08:00
parent 06e1302f06
commit e37b379218
1 changed files with 5 additions and 6 deletions

View File

@ -458,15 +458,14 @@ namespace N_m3u8DL_RE.DownloadManager
FileDic!.Remove(badKey, out _); FileDic!.Remove(badKey, out _);
} }
//检测目标文件是否存在
while (!readInfo && File.Exists(output))
{
Logger.WarnMarkUp($"{Path.GetFileName(output)} => {Path.GetFileName(output = Path.ChangeExtension(output, $"copy" + Path.GetExtension(output)))}");
}
//设置输出流 //设置输出流
if (fileOutputStream == null) if (fileOutputStream == null)
{ {
//检测目标文件是否存在
while (File.Exists(output))
{
Logger.WarnMarkUp($"{Path.GetFileName(output)} => {Path.GetFileName(output = Path.ChangeExtension(output, $"copy" + Path.GetExtension(output)))}");
}
fileOutputStream = new FileStream(output, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read); fileOutputStream = new FileStream(output, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);
} }