修复bug: 若skip-merge和save-dir同时使用,则save-dir不能生效 #817
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题分析
根据源码分析,当使用 --skip-merge 参数时,程序SimpleDownloadManager.cs存在以下问题:
跳过合并步骤:当 SkipMerge 为 true 时,程序直接跳过合并逻辑,不会执行文件合并操作。
文件保存逻辑问题:在 SkipMerge 为 true 的情况下,程序只检查合并后的输出文件是否存在,但不会将分片文件保存到指定的输出目录。
临时文件清理:程序在 SkipMerge 为 false 时会删除临时文件,但在 SkipMerge 为 true 时没有相应的文件保存逻辑
关键源码问题
在 /workspace/N_m3u8DL-RE-src/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs 中:
// 记录所有文件信息
if (File.Exists(output))
{
OutputFiles.Add(new OutputFile()
{
Index = task.Id,
FilePath = output,
LangCode = streamSpec.Language,
Description = streamSpec.Name,
Mediainfos = mediaInfos,
MediaType = streamSpec.MediaType,
});
}
问题:这段代码只在合并后的输出文件存在时才记录文件信息.当 SkipMerge 为 true 时, output 文件不存在,因此不会记录任何文件信息,导致下载的分片文件没有被保存到指定位置
解决措施见代码注释.以上仅个人见解,希望老大采纳