|
|
@ -142,20 +142,26 @@ namespace DownKyi.Services.Download
|
|
|
|
|
|
|
|
|
|
|
|
// 下载文件名
|
|
|
|
// 下载文件名
|
|
|
|
string fileName = Guid.NewGuid().ToString("N");
|
|
|
|
string fileName = Guid.NewGuid().ToString("N");
|
|
|
|
|
|
|
|
|
|
|
|
string key = $"{downloadVideo.Id}_{downloadVideo.Codecs}";
|
|
|
|
string key = $"{downloadVideo.Id}_{downloadVideo.Codecs}";
|
|
|
|
|
|
|
|
|
|
|
|
// 老版本数据库没有这一项,会变成null
|
|
|
|
// 老版本数据库没有这一项,会变成null
|
|
|
|
if (downloading.Downloading.DownloadedFiles == null)
|
|
|
|
if (downloading.Downloading.DownloadedFiles == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
downloading.Downloading.DownloadedFiles = new List<string>();
|
|
|
|
downloading.Downloading.DownloadedFiles = new List<string>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (downloading.Downloading.DownloadFiles.ContainsKey(key))
|
|
|
|
if (downloading.Downloading.DownloadFiles.ContainsKey(key))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// 如果存在,表示下载过,
|
|
|
|
// 如果存在,表示下载过,
|
|
|
|
// 则继续使用上次下载的文件名
|
|
|
|
// 则继续使用上次下载的文件名
|
|
|
|
fileName = downloading.Downloading.DownloadFiles[key];
|
|
|
|
fileName = downloading.Downloading.DownloadFiles[key];
|
|
|
|
|
|
|
|
|
|
|
|
// 还要检查一下文件有没有被人删掉,删掉的话重新下载
|
|
|
|
// 还要检查一下文件有没有被人删掉,删掉的话重新下载
|
|
|
|
// 如果下载视频之后音频文件被人删了。此时gid还是视频的,会下错文件
|
|
|
|
// 如果下载视频之后音频文件被人删了。此时gid还是视频的,会下错文件
|
|
|
|
if (downloading.Downloading.DownloadedFiles.Contains(key) && File.Exists(Path.Combine(path, fileName)))
|
|
|
|
if (downloading.Downloading.DownloadedFiles.Contains(key) && File.Exists(Path.Combine(path, fileName)))
|
|
|
|
|
|
|
|
{
|
|
|
|
return Path.Combine(path, fileName);
|
|
|
|
return Path.Combine(path, fileName);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|