当目标文件存在时,增加后缀而不是直接覆盖

This commit is contained in:
nilaoda 2022-07-27 01:46:05 +08:00
parent 57e22042cd
commit f4e8b3f908
1 changed files with 5 additions and 0 deletions

View File

@ -52,6 +52,11 @@ namespace N_m3u8DL_RE.DownloadManager
dirName = ConvertUtil.GetValidFileName(dirName, filterSlash: true); dirName = ConvertUtil.GetValidFileName(dirName, filterSlash: true);
var headers = DownloaderConfig.Headers; var headers = DownloaderConfig.Headers;
var output = Path.Combine(saveDir, saveName + $".{streamSpec.Extension ?? "ts"}"); var output = Path.Combine(saveDir, saveName + $".{streamSpec.Extension ?? "ts"}");
//检测目标文件是否存在
while (File.Exists(output))
{
Logger.WarnMarkUp($"{output} => {output = Path.ChangeExtension(output, $"copy" + Path.GetExtension(output))}");
}
//mp4decrypt //mp4decrypt
var mp4decrypt = DownloaderConfig.DecryptionBinaryPath!; var mp4decrypt = DownloaderConfig.DecryptionBinaryPath!;