修复因下载列表中的重复内容导致的闪退问题

pull/253/head
leiurayer 2 years ago
parent 577631c295
commit c42147cf28

@ -160,11 +160,11 @@ namespace DownKyi.Core.Storage.Database.Download
{
Dictionary<string, object> objects = new Dictionary<string, object>();
try
dbHelper.ExecuteQuery(sql, reader =>
{
dbHelper.ExecuteQuery(sql, reader =>
while (reader.Read())
{
while (reader.Read())
try
{
// 读取字节数组
byte[] array = (byte[])reader["data"];
@ -177,18 +177,17 @@ namespace DownKyi.Core.Storage.Database.Download
objects.Add((string)reader["id"], obj);
}
});
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("Query()发生异常: {0}", e);
LogManager.Error($"{tableName}", e);
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("Query()发生异常: {0}", e);
LogManager.Error($"{tableName}", e);
}
}
});
return objects;
}
/// <summary>
/// 如果表不存在则创建表
/// </summary>

@ -32,8 +32,8 @@ namespace DownKyi.Services.Download
{
private CancellationTokenSource tokenSource;
private int retry = 5;
private string nullMark = "<null>";
private readonly int retry = 5;
private readonly string nullMark = "<null>";
public AriaDownloadService(ObservableCollection<DownloadingItem> downloadingList, ObservableCollection<DownloadedItem> downloadedList) : base(downloadingList, downloadedList)
{
@ -582,13 +582,13 @@ namespace DownKyi.Services.Download
for (int i = 0; i < retry; i++)
{
audioUid = DownloadAudio(downloading);
if (audioUid != null && audioUid != "<null>")
if (audioUid != null && audioUid != nullMark)
{
break;
}
}
}
if (audioUid == "<null>")
if (audioUid == nullMark)
{
DownloadFailed(downloading);
return;
@ -611,13 +611,13 @@ namespace DownKyi.Services.Download
for (int i = 0; i < retry; i++)
{
videoUid = DownloadVideo(downloading);
if (videoUid != null && videoUid != "<null>")
if (videoUid != null && videoUid != nullMark)
{
break;
}
}
}
if (videoUid == "<null>")
if (videoUid == nullMark)
{
DownloadFailed(downloading);
return;

@ -84,6 +84,8 @@ namespace DownKyi.ViewModels.DownloadManager
/// </summary>
private void ExecuteOpenFolderCommand()
{
if (DownloadBase == null) { return; }
string videoPath = $"{DownloadBase.FilePath}.mp4";
FileInfo fileInfo = new FileInfo(videoPath);
if (File.Exists(fileInfo.FullName))
@ -105,6 +107,8 @@ namespace DownKyi.ViewModels.DownloadManager
/// </summary>
private void ExecuteOpenVideoCommand()
{
if (DownloadBase == null) { return; }
string videoPath = $"{DownloadBase.FilePath}.mp4";
var fileInfo = new FileInfo(videoPath);
if (File.Exists(fileInfo.FullName))

Loading…
Cancel
Save