Fix taskIds being changed during requests
This commit is contained in:
parent
e541b922dc
commit
0a51e7ad3d
@ -152,7 +152,7 @@ public class RequestHandler
|
|||||||
_taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName1).Value;
|
_taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName1).Value;
|
||||||
if (connector1 is null)
|
if (connector1 is null)
|
||||||
return;
|
return;
|
||||||
Publication? publication1 = _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId1);
|
Publication? publication1 = _taskManager.GetAllPublications().FirstOrDefault(pub => string.Concat(TrangaSettings.CleanIdRex.Matches(pub.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId1)));
|
||||||
if (publication1 is null)
|
if (publication1 is null)
|
||||||
return;
|
return;
|
||||||
_taskManager.AddTask(new MonitorPublicationTask(connectorName1, (Publication)publication1, TimeSpan.Parse(reoccurrenceTime1), language1 ?? "en"));
|
_taskManager.AddTask(new MonitorPublicationTask(connectorName1, (Publication)publication1, TimeSpan.Parse(reoccurrenceTime1), language1 ?? "en"));
|
||||||
@ -174,7 +174,7 @@ public class RequestHandler
|
|||||||
_taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName2).Value;
|
_taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName2).Value;
|
||||||
if (connector2 is null)
|
if (connector2 is null)
|
||||||
return;
|
return;
|
||||||
Publication? publication2 = _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId2);
|
Publication? publication2 = _taskManager.GetAllPublications().FirstOrDefault(pub => string.Concat(TrangaSettings.CleanIdRex.Matches(pub.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId2)));
|
||||||
if (publication2 is null)
|
if (publication2 is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ public class RequestHandler
|
|||||||
variables.TryGetValue("internalId", out string? internalId1);
|
variables.TryGetValue("internalId", out string? internalId1);
|
||||||
if(internalId1 is null)
|
if(internalId1 is null)
|
||||||
return _taskManager.GetAllPublications();
|
return _taskManager.GetAllPublications();
|
||||||
return new [] { _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId1) };
|
return new [] { _taskManager.GetAllPublications().FirstOrDefault(pub => string.Concat(TrangaSettings.CleanIdRex.Matches(pub.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId1))) };
|
||||||
case "/Publications/FromConnector":
|
case "/Publications/FromConnector":
|
||||||
variables.TryGetValue("connectorName", out string? connectorName1);
|
variables.TryGetValue("connectorName", out string? connectorName1);
|
||||||
variables.TryGetValue("title", out string? title);
|
variables.TryGetValue("title", out string? title);
|
||||||
@ -288,7 +288,7 @@ public class RequestHandler
|
|||||||
Connector? connector2 = _taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName2).Value;
|
Connector? connector2 = _taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName2).Value;
|
||||||
if (connector2 is null)
|
if (connector2 is null)
|
||||||
return null;
|
return null;
|
||||||
Publication? publication = _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId2);
|
Publication? publication = _taskManager.GetAllPublications().FirstOrDefault(pub => string.Concat(TrangaSettings.CleanIdRex.Matches(pub.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId2)));
|
||||||
if (publication is null)
|
if (publication is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -180,7 +180,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 &&
|
||||||
string.Concat(settings.CleanIdRex.Matches(mpt.publication.internalId)) == string.Concat(settings.CleanIdRex.Matches(internalId)));
|
string.Concat(TrangaSettings.CleanIdRex.Matches(mpt.publication.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return _allTasks.Where(tTask =>
|
return _allTasks.Where(tTask =>
|
||||||
@ -200,7 +200,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 &&
|
||||||
string.Concat(settings.CleanIdRex.Matches(dct.publication.internalId)) == string.Concat(settings.CleanIdRex.Matches(internalId)) &&
|
string.Concat(TrangaSettings.CleanIdRex.Matches(dct.publication.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId)) &&
|
||||||
dct.chapter.sortNumber == chapterSortNumber);
|
dct.chapter.sortNumber == chapterSortNumber);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -16,7 +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]*-*_*");
|
[JsonIgnore] public static 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