Fix taskIds being changed during requests
This commit is contained in:
parent
a16686dfbf
commit
b515215f4b
@ -128,18 +128,15 @@ public class TaskManager
|
|||||||
_allTasks.Add(newTask);
|
_allTasks.Add(newTask);
|
||||||
break;
|
break;
|
||||||
case TrangaTask.Task.MonitorPublication:
|
case TrangaTask.Task.MonitorPublication:
|
||||||
if (!_allTasks.Any(mTask => mTask is MonitorPublicationTask mpt && newTask is MonitorPublicationTask nMpt &&
|
MonitorPublicationTask mpt = (MonitorPublicationTask)newTask;
|
||||||
mpt.publication.internalId == nMpt.publication.internalId &&
|
if(!GetTasksMatching(mpt.task, mpt.connectorName, internalId:mpt.publication.internalId).Any())
|
||||||
mpt.connectorName == nMpt.connectorName))
|
|
||||||
_allTasks.Add(newTask);
|
_allTasks.Add(newTask);
|
||||||
else
|
else
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"Task already exists {newTask}");
|
logger?.WriteLine(this.GetType().ToString(), $"Task already exists {newTask}");
|
||||||
break;
|
break;
|
||||||
case TrangaTask.Task.DownloadChapter:
|
case TrangaTask.Task.DownloadChapter:
|
||||||
if (!_allTasks.Any(mTask => mTask is DownloadChapterTask dct && newTask is DownloadChapterTask nDct &&
|
DownloadChapterTask dct = (DownloadChapterTask)newTask;
|
||||||
dct.publication.internalId == nDct.publication.internalId &&
|
if(!GetTasksMatching(dct.task, dct.connectorName, internalId:dct.publication.internalId, chapterSortNumber:dct.chapter.sortNumber).Any())
|
||||||
dct.connectorName == nDct.connectorName &&
|
|
||||||
dct.chapter.sortNumber == nDct.chapter.sortNumber))
|
|
||||||
_allTasks.Add(newTask);
|
_allTasks.Add(newTask);
|
||||||
else
|
else
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"Task already exists {newTask}");
|
logger?.WriteLine(this.GetType().ToString(), $"Task already exists {newTask}");
|
||||||
@ -182,7 +179,7 @@ public class TaskManager
|
|||||||
{
|
{
|
||||||
return _allTasks.Where(mTask =>
|
return _allTasks.Where(mTask =>
|
||||||
mTask is MonitorPublicationTask mpt && mpt.connectorName == connectorName &&
|
mTask is MonitorPublicationTask mpt && mpt.connectorName == connectorName &&
|
||||||
mpt.publication.internalId == internalId);
|
string.Concat(settings.CleanIdRex.Matches(mpt.publication.internalId)) == string.Concat(settings.CleanIdRex.Matches(internalId)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return _allTasks.Where(tTask =>
|
return _allTasks.Where(tTask =>
|
||||||
@ -202,7 +199,7 @@ public class TaskManager
|
|||||||
{
|
{
|
||||||
return _allTasks.Where(mTask =>
|
return _allTasks.Where(mTask =>
|
||||||
mTask is DownloadChapterTask dct && dct.connectorName == connectorName &&
|
mTask is DownloadChapterTask dct && dct.connectorName == connectorName &&
|
||||||
dct.publication.publicationId == internalId &&
|
string.Concat(settings.CleanIdRex.Matches(dct.publication.internalId)) == string.Concat(settings.CleanIdRex.Matches(internalId)) &&
|
||||||
dct.chapter.sortNumber == chapterSortNumber);
|
dct.chapter.sortNumber == chapterSortNumber);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Logging;
|
using System.Text.RegularExpressions;
|
||||||
|
using Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Tranga.LibraryManagers;
|
using Tranga.LibraryManagers;
|
||||||
using Tranga.NotificationManagers;
|
using Tranga.NotificationManagers;
|
||||||
@ -15,6 +16,7 @@ public class TrangaSettings
|
|||||||
[JsonIgnore] public string coverImageCache => Path.Join(workingDirectory, "imageCache");
|
[JsonIgnore] public string coverImageCache => Path.Join(workingDirectory, "imageCache");
|
||||||
public HashSet<LibraryManager> libraryManagers { get; }
|
public HashSet<LibraryManager> libraryManagers { get; }
|
||||||
public HashSet<NotificationManager> notificationManagers { get; }
|
public HashSet<NotificationManager> notificationManagers { get; }
|
||||||
|
[JsonIgnore]internal Regex CleanIdRex = new (@"[a-zA-Z0-9]*-*_*");
|
||||||
|
|
||||||
public TrangaSettings(string downloadLocation, string workingDirectory, HashSet<LibraryManager>? libraryManagers,
|
public TrangaSettings(string downloadLocation, string workingDirectory, HashSet<LibraryManager>? libraryManagers,
|
||||||
HashSet<NotificationManager>? notificationManagers)
|
HashSet<NotificationManager>? notificationManagers)
|
||||||
|
Loading…
Reference in New Issue
Block a user