Fix taskIds being changed during requests, no workaround this time
This commit is contained in:
parent
0a51e7ad3d
commit
4f01c1166f
@ -80,12 +80,16 @@ public class RequestHandler
|
|||||||
private Dictionary<string, string> GetRequestVariables(string query)
|
private Dictionary<string, string> GetRequestVariables(string query)
|
||||||
{
|
{
|
||||||
Dictionary<string, string> ret = new();
|
Dictionary<string, string> ret = new();
|
||||||
Regex queryRex = new (@"\?{1}&?([A-z]+=[A-z]+)+(&[A-z]+=[A-z]+)*");
|
Regex queryRex = new (@"\?{1}&?([A-z0-9-=]+=[A-z0-9-=]+)+(&[A-z0-9-=]+=[A-z0-9-=]+)*");
|
||||||
if (!queryRex.IsMatch(query))
|
if (!queryRex.IsMatch(query))
|
||||||
return ret;
|
return ret;
|
||||||
query = query.Substring(1);
|
query = query.Substring(1);
|
||||||
foreach(string kvpair in query.Split('&').Where(str => str.Length>=3 ))
|
foreach (string kvpair in query.Split('&').Where(str => str.Length >= 3))
|
||||||
ret.Add(kvpair.Split('=')[0], kvpair.Split('=')[1]);
|
{
|
||||||
|
string var = kvpair.Split('=')[0];
|
||||||
|
string val = kvpair.Substring(var.Length + 1);
|
||||||
|
ret.Add(var, val);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +156,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 => string.Concat(TrangaSettings.CleanIdRex.Matches(pub.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId1)));
|
Publication? publication1 = _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == 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 +178,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 => string.Concat(TrangaSettings.CleanIdRex.Matches(pub.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId2)));
|
Publication? publication2 = _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId2);
|
||||||
if (publication2 is null)
|
if (publication2 is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -261,7 +265,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 => string.Concat(TrangaSettings.CleanIdRex.Matches(pub.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId1))) };
|
return new [] { _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == 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 +292,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 => string.Concat(TrangaSettings.CleanIdRex.Matches(pub.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId2)));
|
Publication? publication = _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == 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(TrangaSettings.CleanIdRex.Matches(mpt.publication.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId)));
|
mpt.publication.internalId == 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(TrangaSettings.CleanIdRex.Matches(dct.publication.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId)) &&
|
dct.publication.internalId == internalId &&
|
||||||
dct.chapter.sortNumber == chapterSortNumber);
|
dct.chapter.sortNumber == chapterSortNumber);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -16,7 +16,6 @@ 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] 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