Merge branch 'refs/heads/cuttingedge-merge-ServerV2' into Server-V2
# Conflicts: # Tranga/Jobs/JobBoss.cs
This commit is contained in:
commit
3e581e2ddb
@ -89,13 +89,15 @@ public readonly struct Chapter : IComparable
|
||||
return false;
|
||||
FileInfo? mangaArchive = null;
|
||||
string markerPath = Path.Join(mangaDirectory, $".{id}");
|
||||
if (this.id is not null
|
||||
&& File.Exists(markerPath)
|
||||
&& File.Exists(File.ReadAllText(markerPath)))
|
||||
if (this.id is not null && File.Exists(markerPath))
|
||||
{
|
||||
if(File.Exists(File.ReadAllText(markerPath)))
|
||||
mangaArchive = new FileInfo(File.ReadAllText(markerPath));
|
||||
}
|
||||
else
|
||||
File.Delete(markerPath);
|
||||
}
|
||||
|
||||
if(mangaArchive is null)
|
||||
{
|
||||
FileInfo[] archives = new DirectoryInfo(mangaDirectory).GetFiles("*.cbz");
|
||||
Regex volChRex = new(@"(?:Vol(?:ume)?\.([0-9]+)\D*)?Ch(?:apter)?\.([0-9]+(?:\.[0-9]+)*)");
|
||||
@ -110,6 +112,7 @@ public readonly struct Chapter : IComparable
|
||||
return m.Groups[2].Value == t.chapterNumber;
|
||||
});
|
||||
}
|
||||
|
||||
string correctPath = GetArchiveFilePath();
|
||||
if(mangaArchive is not null && mangaArchive.FullName != correctPath)
|
||||
mangaArchive.MoveTo(correctPath, true);
|
||||
|
@ -1,6 +1,8 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
using Tranga.MangaConnectors;
|
||||
using static System.IO.UnixFileMode;
|
||||
|
||||
namespace Tranga.Jobs;
|
||||
|
||||
@ -17,7 +19,7 @@ public class JobBoss : GlobalBase
|
||||
Log($"Next job in {jobs.MinBy(job => job.nextExecution)?.nextExecution.Subtract(DateTime.Now)} {jobs.MinBy(job => job.nextExecution)?.id}");
|
||||
}
|
||||
|
||||
public bool AddJob(Job job)
|
||||
public bool AddJob(Job job, string? jobFile = null)
|
||||
{
|
||||
if (ContainsJobLike(job))
|
||||
{
|
||||
@ -27,10 +29,11 @@ public class JobBoss : GlobalBase
|
||||
else
|
||||
{
|
||||
Log($"Added {job}");
|
||||
this.jobs.Add(job);
|
||||
UpdateJobFile(job);
|
||||
return true;
|
||||
if (!this.jobs.Add(job))
|
||||
return false;
|
||||
UpdateJobFile(job, jobFile);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void AddJobs(IEnumerable<Job> jobsToAdd)
|
||||
@ -139,12 +142,12 @@ public class JobBoss : GlobalBase
|
||||
}
|
||||
|
||||
private void LoadJobsList(HashSet<MangaConnector> connectors)
|
||||
{
|
||||
if (!Directory.Exists(TrangaSettings.jobsFolderPath)) //No jobs to load
|
||||
{
|
||||
Directory.CreateDirectory(TrangaSettings.jobsFolderPath);
|
||||
if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
File.SetUnixFileMode(TrangaSettings.jobsFolderPath, UserRead | UserWrite | UserExecute | GroupRead | OtherRead);
|
||||
if (!Directory.Exists(TrangaSettings.jobsFolderPath)) //No jobs to load
|
||||
return;
|
||||
}
|
||||
Regex idRex = new (@"(.*)\.json");
|
||||
|
||||
//Load Manga-Files
|
||||
@ -165,8 +168,8 @@ public class JobBoss : GlobalBase
|
||||
else
|
||||
{
|
||||
Log($"Adding Job {job}");
|
||||
this.jobs.Add(job);
|
||||
UpdateJobFile(job, file.Name);
|
||||
if(!AddJob(job, file.Name)) //If we detect a duplicate, delete the file.
|
||||
file.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,7 +221,8 @@ public class JobBoss : GlobalBase
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log(e.ToString());
|
||||
Log($"Error deleting {oldFilePath} job {job.id}\n{e}");
|
||||
return; //Don't export a new file when we haven't actually deleted the old one
|
||||
}
|
||||
}
|
||||
|
||||
@ -230,6 +234,8 @@ public class JobBoss : GlobalBase
|
||||
while(IsFileInUse(newJobFilePath))
|
||||
Thread.Sleep(10);
|
||||
File.WriteAllText(newJobFilePath, jobStr);
|
||||
if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
File.SetUnixFileMode(newJobFilePath, UserRead | UserWrite | GroupRead | OtherRead);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,9 +108,10 @@ public class ManhuaPlus : MangaConnector
|
||||
Log("No genres found");
|
||||
}
|
||||
|
||||
string yearNodeStr = document.DocumentNode
|
||||
.SelectSingleNode("//aside//i[contains(concat(' ',normalize-space(@class),' '),' fa-clock ')]/../span").InnerText.Replace("\n", "");
|
||||
int year = int.Parse(yearNodeStr.Split(' ')[0].Split('/')[^1]);
|
||||
Regex yearRex = new(@"(?:[0-9]{1,2}\/){2}([0-9]{2,4}) [0-9]{1,2}:[0-9]{1,2}");
|
||||
HtmlNode yearNode = document.DocumentNode.SelectSingleNode("//aside//i[contains(concat(' ',normalize-space(@class),' '),' fa-clock ')]/../span");
|
||||
Match match = yearRex.Match(yearNode.InnerText);
|
||||
int year = match.Success && match.Groups[1].Success ? int.Parse(match.Groups[1].Value) : 1960;
|
||||
|
||||
status = document.DocumentNode.SelectSingleNode("//aside//i[contains(concat(' ',normalize-space(@class),' '),' fa-rss ')]/../span").InnerText.Replace("\n", "");
|
||||
switch (status.ToLower())
|
||||
|
Loading…
Reference in New Issue
Block a user