mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-13 06:47:54 +02:00
#168 Multiple Base-Paths (Libraries) Support
Some checks failed
Docker Image CI / build (push) Has been cancelled
Some checks failed
Docker Image CI / build (push) Has been cancelled
This commit is contained in:
@ -14,7 +14,7 @@ public class DownloadMangaCoverJob(string mangaId, string? parentJobId = null, I
|
||||
|
||||
protected override IEnumerable<Job> RunInternal(PgsqlContext context)
|
||||
{
|
||||
Manga? manga = Manga ?? context.Manga.Find(this.MangaId);
|
||||
Manga? manga = Manga ?? context.Mangas.Find(this.MangaId);
|
||||
if (manga is null)
|
||||
return [];
|
||||
|
||||
|
@ -25,10 +25,10 @@ public class DownloadSingleChapterJob(string chapterId, string? parentJobId = nu
|
||||
protected override IEnumerable<Job> RunInternal(PgsqlContext context)
|
||||
{
|
||||
Chapter chapter = Chapter ?? context.Chapters.Find(ChapterId)!;
|
||||
Manga manga = chapter.ParentManga ?? context.Manga.Find(chapter.ParentMangaId)!;
|
||||
Manga manga = chapter.ParentManga ?? context.Mangas.Find(chapter.ParentMangaId)!;
|
||||
MangaConnector connector = manga.MangaConnector ?? context.MangaConnectors.Find(manga.MangaConnectorId)!;
|
||||
string[] imageUrls = connector.GetChapterImageUrls(chapter);
|
||||
string saveArchiveFilePath = chapter.GetArchiveFilePath();
|
||||
string saveArchiveFilePath = chapter.FullArchiveFilePath;
|
||||
|
||||
//Check if Publication Directory already exists
|
||||
string directoryPath = Path.GetDirectoryName(saveArchiveFilePath)!;
|
||||
|
@ -9,5 +9,6 @@ public enum JobType : byte
|
||||
MoveFileOrFolderJob = 3,
|
||||
DownloadMangaCoverJob = 4,
|
||||
RetrieveChaptersJob = 5,
|
||||
UpdateFilesDownloadedJob = 6
|
||||
UpdateFilesDownloadedJob = 6,
|
||||
MoveMangaLibraryJob = 7
|
||||
}
|
30
API/Schema/Jobs/MoveMangaLibraryJob.cs
Normal file
30
API/Schema/Jobs/MoveMangaLibraryJob.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace API.Schema.Jobs;
|
||||
|
||||
public class MoveMangaLibraryJob(string mangaId, string toLibraryId, string? parentJobId = null, ICollection<string>? dependsOnJobsIds = null)
|
||||
: Job(TokenGen.CreateToken(typeof(MoveMangaLibraryJob)), JobType.MoveMangaLibraryJob, 0, parentJobId, dependsOnJobsIds)
|
||||
{
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public string MangaId { get; init; } = mangaId;
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public string ToLibraryId { get; init; } = toLibraryId;
|
||||
|
||||
protected override IEnumerable<Job> RunInternal(PgsqlContext context)
|
||||
{
|
||||
Manga? manga = context.Mangas.Find(MangaId);
|
||||
if(manga is null)
|
||||
throw new KeyNotFoundException();
|
||||
LocalLibrary? library = context.LocalLibraries.Find(ToLibraryId);
|
||||
if(library is null)
|
||||
throw new KeyNotFoundException();
|
||||
Chapter[] chapters = context.Chapters.Where(c => c.ParentMangaId == MangaId).ToArray();
|
||||
Dictionary<Chapter, string> oldPath = chapters.ToDictionary(c => c, c => c.FullArchiveFilePath!);
|
||||
manga.Library = library;
|
||||
context.SaveChanges();
|
||||
|
||||
return chapters.Select(c => new MoveFileOrFolderJob(oldPath[c], c.FullArchiveFilePath!));
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ public class RetrieveChaptersJob(ulong recurrenceMs, string mangaId, string? par
|
||||
* Manga as a new entity and Postgres throws a Duplicate PK exception.
|
||||
* m.MangaConnector does not have this issue (IDK why).
|
||||
*/
|
||||
Manga m = context.Manga.Find(MangaId)!;
|
||||
Manga m = context.Mangas.Find(MangaId)!;
|
||||
MangaConnector connector = context.MangaConnectors.Find(m.MangaConnectorId)!;
|
||||
// This gets all chapters that are not downloaded
|
||||
Chapter[] allNewChapters = connector.GetNewChapters(m).DistinctBy(c => c.ChapterId).ToArray();
|
||||
|
Reference in New Issue
Block a user