Compare commits

..

No commits in common. "7a14583d6ac7da94f8c442382906678ed55f8429" and "b6cdb07e3f59fd23d716ee521dae0886472dc88d" have entirely different histories.

5 changed files with 5 additions and 11 deletions

View File

@ -1,5 +1,4 @@
using System.Globalization; using System.Globalization;
using System.Text.RegularExpressions;
using Logging; using Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using Tranga.LibraryConnectors; using Tranga.LibraryConnectors;
@ -15,7 +14,6 @@ public abstract class GlobalBase
protected HashSet<LibraryConnector> libraryConnectors { get; init; } protected HashSet<LibraryConnector> libraryConnectors { get; init; }
protected List<Manga> cachedPublications { get; init; } protected List<Manga> cachedPublications { get; init; }
protected static readonly NumberFormatInfo numberFormatDecimalPoint = new (){ NumberDecimalSeparator = "." }; protected static readonly NumberFormatInfo numberFormatDecimalPoint = new (){ NumberDecimalSeparator = "." };
protected static readonly Regex baseUrlRex = new(@"https?:\/\/[0-9A-z\.]*");
protected GlobalBase(GlobalBase clone) protected GlobalBase(GlobalBase clone)
{ {

View File

@ -165,12 +165,12 @@ public class JobBoss : GlobalBase
public void ExportJob(Job job) public void ExportJob(Job job)
{ {
string jobFilePath = Path.Join(settings.jobsFolderPath, $"{job.id}.json"); string jobFilePath = Path.Join(settings.jobsFolderPath, $"{job.id}.json");
Log($"Exporting Job {jobFilePath}");
if (!this.jobs.Any(jjob => jjob.id == job.id)) if (!this.jobs.Any(jjob => jjob.id == job.id))
{ {
try try
{ {
Log($"Deleting Job-file {jobFilePath}");
while(IsFileInUse(jobFilePath)) while(IsFileInUse(jobFilePath))
Thread.Sleep(10); Thread.Sleep(10);
File.Delete(jobFilePath); File.Delete(jobFilePath);
@ -182,7 +182,6 @@ public class JobBoss : GlobalBase
} }
else else
{ {
Log($"Exporting Job {jobFilePath}");
string jobStr = JsonConvert.SerializeObject(job); string jobStr = JsonConvert.SerializeObject(job);
while(IsFileInUse(jobFilePath)) while(IsFileInUse(jobFilePath))
Thread.Sleep(10); Thread.Sleep(10);

View File

@ -21,10 +21,10 @@ public abstract class LibraryConnector : GlobalBase
protected LibraryConnector(GlobalBase clone, string baseUrl, string auth, LibraryType libraryType) : base(clone) protected LibraryConnector(GlobalBase clone, string baseUrl, string auth, LibraryType libraryType) : base(clone)
{ {
Log($"Creating libraryConnector {Enum.GetName(libraryType)}"); Regex urlRex = new(@"https?:\/\/[0-9A-z\.]*");
if (!baseUrlRex.IsMatch(baseUrl)) if (!urlRex.IsMatch(baseUrl))
throw new ArgumentException("Base url does not match pattern"); throw new ArgumentException("Base url does not match pattern");
this.baseUrl = baseUrlRex.Match(baseUrl).Value; this.baseUrl = urlRex.Match(baseUrl).Value;
this.auth = auth; this.auth = auth;
this.libraryType = libraryType; this.libraryType = libraryType;
} }

View File

@ -13,9 +13,7 @@ public class Gotify : NotificationConnector
[JsonConstructor] [JsonConstructor]
public Gotify(GlobalBase clone, string endpoint, string appToken) : base(clone, NotificationConnectorType.Gotify) public Gotify(GlobalBase clone, string endpoint, string appToken) : base(clone, NotificationConnectorType.Gotify)
{ {
if (!baseUrlRex.IsMatch(endpoint)) this.endpoint = endpoint;
throw new ArgumentException("endpoint does not match pattern");
this.endpoint = baseUrlRex.Match(endpoint).Value;;
this.appToken = appToken; this.appToken = appToken;
} }

View File

@ -6,7 +6,6 @@ public abstract class NotificationConnector : GlobalBase
protected NotificationConnector(GlobalBase clone, NotificationConnectorType notificationConnectorType) : base(clone) protected NotificationConnector(GlobalBase clone, NotificationConnectorType notificationConnectorType) : base(clone)
{ {
Log($"Creating notificationConnector {Enum.GetName(notificationConnectorType)}");
this.notificationConnectorType = notificationConnectorType; this.notificationConnectorType = notificationConnectorType;
} }