Skip to content

Commit

Permalink
不删除整个临时文件夹而是只删除新建的子文件夹 (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
RikaCelery authored Dec 18, 2023
1 parent 8427241 commit 353952e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,9 @@ await Parallel.ForEachAsync(segments, options, async (seg, _) =>
{
File.Delete(file);
}
OtherUtil.SafeDeleteDir(tmpDir);
OtherUtil.SafeDeleteDir(tmpDir);
// Logger.Info("Don't Delete {} SimpleDownloadManager.cs Line574",tmpDir);

}

//重新读取init信息
Expand Down Expand Up @@ -686,7 +688,8 @@ await Parallel.ForEachAsync(dic, async (kp, _) =>
var file = Path.Combine(DownloaderConfig.DirPrefix, item.Key);
if (File.Exists(file)) File.Delete(file);
}
OtherUtil.SafeDeleteDir(DownloaderConfig.DirPrefix);
// OtherUtil.SafeDeleteDir(DownloaderConfig.ActualTmpDir);
Logger.Info("Don't Delete {} SimpleDownloadManager.cs Line692",DownloaderConfig.DirPrefix);
}

//混流
Expand Down Expand Up @@ -720,7 +723,9 @@ await Parallel.ForEachAsync(dic, async (kp, _) =>
Logger.WarnMarkUp("[grey]Cleaning files...[/]");
OutputFiles.ForEach(f => File.Delete(f.FilePath));
var tmpDir = DownloaderConfig.MyOptions.TmpDir ?? Environment.CurrentDirectory;
OtherUtil.SafeDeleteDir(tmpDir);
// OtherUtil.SafeDeleteDir(tmpDir);
Logger.Info("Don't Delete {} SimpleDownloadManager.cs Line727",tmpDir);

}
}
else
Expand Down
7 changes: 5 additions & 2 deletions src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ private async Task<bool> RecordStreamAsync(StreamSpec streamSpec, ProgressTask t
var type = streamSpec.MediaType ?? Common.Enum.MediaType.VIDEO;
var dirName = $"{task.Id}_{OtherUtil.GetValidFileName(streamSpec.GroupId ?? "", "-")}_{streamSpec.Codecs}_{streamSpec.Bandwidth}_{streamSpec.Language}";
var tmpDir = Path.Combine(DownloaderConfig.DirPrefix, dirName);
// DownloaderConfig.ActualTmpDir = tmpDir;
var saveDir = DownloaderConfig.MyOptions.SaveDir ?? Environment.CurrentDirectory;
var saveName = DownloaderConfig.MyOptions.SaveName != null ? $"{DownloaderConfig.MyOptions.SaveName}.{streamSpec.Language}".TrimEnd('.') : dirName;
var headers = DownloaderConfig.Headers;
Expand Down Expand Up @@ -877,7 +878,8 @@ await Parallel.ForEachAsync(dic, options, async (kp, _) =>
var file = Path.Combine(DownloaderConfig.DirPrefix, item.Key);
if (File.Exists(file)) File.Delete(file);
}
OtherUtil.SafeDeleteDir(DownloaderConfig.DirPrefix);
// OtherUtil.SafeDeleteDir(DownloaderConfig.DirPrefix);
Logger.Info("Don't Delete {} SimpleLoveRecorderManager2.cs Line878",DownloaderConfig.DirPrefix);
}

//混流
Expand Down Expand Up @@ -911,7 +913,8 @@ await Parallel.ForEachAsync(dic, options, async (kp, _) =>
Logger.WarnMarkUp("[grey]Cleaning files...[/]");
OutputFiles.ForEach(f => File.Delete(f.FilePath));
var tmpDir = DownloaderConfig.MyOptions.TmpDir ?? Environment.CurrentDirectory;
OtherUtil.SafeDeleteDir(tmpDir);
// OtherUtil.SafeDeleteDir(tmpDir);
Logger.Info("Don't Delete {} SimpleLoveRecorderManager2.cs Line913",tmpDir);
}
}
else
Expand Down

0 comments on commit 353952e

Please sign in to comment.