change downloads to concurrentdictionary
This commit is contained in:
@@ -95,7 +95,7 @@ namespace MareSynchronos.WebAPI
|
||||
{
|
||||
File.Delete(tempFile);
|
||||
Logger.Debug("Detected cancellation, removing " + currentDownloadId);
|
||||
CurrentDownloads.Remove(currentDownloadId);
|
||||
CancelDownload(currentDownloadId);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace MareSynchronos.WebAPI
|
||||
}
|
||||
|
||||
Logger.Debug("Download complete, removing " + currentDownloadId);
|
||||
CurrentDownloads.Remove(currentDownloadId);
|
||||
CancelDownload(currentDownloadId);
|
||||
}
|
||||
|
||||
public async Task PushCharacterData(CharacterCacheDto character, List<string> visibleCharacterIds)
|
||||
@@ -288,7 +288,10 @@ namespace MareSynchronos.WebAPI
|
||||
|
||||
public void CancelDownload(int downloadId)
|
||||
{
|
||||
CurrentDownloads.Remove(downloadId);
|
||||
while (CurrentDownloads.ContainsKey(downloadId))
|
||||
{
|
||||
CurrentDownloads.TryRemove(downloadId, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
@@ -93,7 +94,7 @@ namespace MareSynchronos.WebAPI
|
||||
|
||||
public event SimpleStringDelegate? UnpairedFromOther;
|
||||
|
||||
public Dictionary<int, List<DownloadFileTransfer>> CurrentDownloads { get; } = new();
|
||||
public ConcurrentDictionary<int, List<DownloadFileTransfer>> CurrentDownloads { get; } = new();
|
||||
|
||||
public List<FileTransfer> CurrentUploads { get; } = new();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user