Merge branch 'refs/heads/cuttingedge-merge-ServerV2' into Server-V2

# Conflicts:
#	Tranga/GlobalBase.cs
#	Tranga/Jobs/JobBoss.cs
#	Tranga/Jobs/UpdateMetadata.cs
#	Tranga/Manga.cs
#	Tranga/MangaConnectors/Bato.cs
#	Tranga/MangaConnectors/MangaKatana.cs
#	Tranga/MangaConnectors/MangaLife.cs
#	Tranga/MangaConnectors/Manganato.cs
#	Tranga/MangaConnectors/Mangasee.cs
#	Tranga/MangaConnectors/Mangaworld.cs
This commit is contained in:
Glax 2024-04-25 23:34:56 +02:00
commit 3d08b1f9f2
5 changed files with 30 additions and 15 deletions

View File

@ -18,7 +18,6 @@ public abstract class GlobalBase
protected HashSet<NotificationConnector> notificationConnectors { get; init; } protected HashSet<NotificationConnector> notificationConnectors { get; init; }
protected HashSet<LibraryConnector> libraryConnectors { get; init; } protected HashSet<LibraryConnector> libraryConnectors { get; init; }
private Dictionary<string, Manga> cachedPublications { get; init; } private Dictionary<string, Manga> cachedPublications { get; init; }
protected HashSet<MangaConnector> _connectors; protected HashSet<MangaConnector> _connectors;
public static readonly NumberFormatInfo numberFormatDecimalPoint = new (){ NumberDecimalSeparator = "." }; public static readonly NumberFormatInfo numberFormatDecimalPoint = new (){ NumberDecimalSeparator = "." };
protected static readonly Regex baseUrlRex = new(@"https?:\/\/[0-9A-z\.-]+(:[0-9]+)?"); protected static readonly Regex baseUrlRex = new(@"https?:\/\/[0-9A-z\.-]+(:[0-9]+)?");

View File

@ -181,18 +181,18 @@ public class JobBoss : GlobalBase
} }
} }
internal void UpdateJobFile(Job job) internal void UpdateJobFile(Job job, string? oldFile = null)
{ {
string jobFilePath = Path.Join(settings.jobsFolderPath, $"{job.id}.json"); string newJobFilePath = Path.Join(settings.jobsFolderPath, $"{job.id}.json");
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}"); Log($"Deleting Job-file {newJobFilePath}");
while(IsFileInUse(jobFilePath)) while(IsFileInUse(newJobFilePath))
Thread.Sleep(10); Thread.Sleep(10);
File.Delete(jobFilePath); File.Delete(newJobFilePath);
} }
catch (Exception e) catch (Exception e)
{ {
@ -201,11 +201,24 @@ public class JobBoss : GlobalBase
} }
else else
{ {
Log($"Exporting Job {jobFilePath}"); Log($"Exporting Job {newJobFilePath}");
string jobStr = JsonConvert.SerializeObject(job); string jobStr = JsonConvert.SerializeObject(job, Formatting.Indented);
while(IsFileInUse(jobFilePath)) while(IsFileInUse(newJobFilePath))
Thread.Sleep(10); Thread.Sleep(10);
File.WriteAllText(jobFilePath, jobStr); File.WriteAllText(newJobFilePath, jobStr);
}
if(oldFile is not null)
try
{
Log($"Deleting old Job-file {oldFile}");
while(IsFileInUse(oldFile))
Thread.Sleep(10);
File.Delete(oldFile);
}
catch (Exception e)
{
Log(e.ToString());
} }
} }

View File

@ -43,6 +43,7 @@ public class UpdateMetadata : Job
AddMangaToCache(manga.Value.WithMetadata(updatedManga)); AddMangaToCache(manga.Value.WithMetadata(updatedManga));
this.manga.Value.SaveSeriesInfoJson(settings.downloadLocation, true); this.manga.Value.SaveSeriesInfoJson(settings.downloadLocation, true);
this.mangaConnector.CopyCoverFromCacheToDownloadLocation((Manga)manga);
this.progressToken.Complete(); this.progressToken.Complete();
} }
else else

View File

@ -21,7 +21,7 @@ public struct Manga
public string[] tags { get; private set; } public string[] tags { get; private set; }
// ReSharper disable once UnusedAutoPropertyAccessor.Global // ReSharper disable once UnusedAutoPropertyAccessor.Global
public string? coverUrl { get; private set; } public string? coverUrl { get; private set; }
public string? coverFileNameInCache { get; } public string? coverFileNameInCache { get; private set; }
// ReSharper disable once UnusedAutoPropertyAccessor.Global // ReSharper disable once UnusedAutoPropertyAccessor.Global
public Dictionary<string,string> links { get; } public Dictionary<string,string> links { get; }
// ReSharper disable once MemberCanBePrivate.Global // ReSharper disable once MemberCanBePrivate.Global
@ -85,8 +85,9 @@ public struct Manga
altTitles = altTitles.UnionBy(newManga.altTitles, kv => kv.Key).ToDictionary(x => x.Key, x => x.Value), altTitles = altTitles.UnionBy(newManga.altTitles, kv => kv.Key).ToDictionary(x => x.Key, x => x.Value),
tags = tags.Union(newManga.tags).ToArray(), tags = tags.Union(newManga.tags).ToArray(),
releaseStatus = newManga.releaseStatus, releaseStatus = newManga.releaseStatus,
websiteUrl = newManga.websiteUrl,
year = newManga.year, year = newManga.year,
websiteUrl = newManga.websiteUrl coverFileNameInCache = newManga.coverFileNameInCache
}; };
} }
@ -100,7 +101,8 @@ public struct Manga
this.sortName == compareManga.sortName && this.sortName == compareManga.sortName &&
this.latestChapterAvailable.Equals(compareManga.latestChapterAvailable) && this.latestChapterAvailable.Equals(compareManga.latestChapterAvailable) &&
this.authors.All(a => compareManga.authors.Contains(a)) && this.authors.All(a => compareManga.authors.Contains(a)) &&
this.websiteUrl.Equals(compareManga.websiteUrl) && (this.coverFileNameInCache??"").Equals(compareManga.coverFileNameInCache) &&
(this.websiteUrl??"").Equals(compareManga.websiteUrl) &&
this.tags.All(t => compareManga.tags.Contains(t)); this.tags.All(t => compareManga.tags.Contains(t));
} }

View File

@ -5,9 +5,9 @@ namespace Tranga.NotificationConnectors;
public class Ntfy : NotificationConnector public class Ntfy : NotificationConnector
{ {
// ReSharper disable once MemberCanBePrivate.Global // ReSharper disable twice MemberCanBePrivate.Global
public string endpoint { get; init; } public string endpoint { get; init; }
private string auth { get; init; } public string auth { get; init; }
private const string Topic = "tranga"; private const string Topic = "tranga";
private readonly HttpClient _client = new(); private readonly HttpClient _client = new();