mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-17 16:57:54 +02:00
Logging
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace API.Schema.Jobs;
|
||||
|
||||
@ -15,15 +16,29 @@ public class MoveMangaLibraryJob(string mangaId, string toLibraryId, string? par
|
||||
protected override IEnumerable<Job> RunInternal(PgsqlContext context)
|
||||
{
|
||||
Manga? manga = context.Mangas.Find(MangaId);
|
||||
if(manga is null)
|
||||
throw new KeyNotFoundException();
|
||||
if (manga is null)
|
||||
{
|
||||
Log.Error("Manga not found");
|
||||
return [];
|
||||
}
|
||||
LocalLibrary? library = context.LocalLibraries.Find(ToLibraryId);
|
||||
if(library is null)
|
||||
throw new KeyNotFoundException();
|
||||
if (library is null)
|
||||
{
|
||||
Log.Error("LocalLibrary not found");
|
||||
return [];
|
||||
}
|
||||
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();
|
||||
try
|
||||
{
|
||||
context.SaveChanges();
|
||||
}
|
||||
catch (DbUpdateException e)
|
||||
{
|
||||
Log.Error(e);
|
||||
return [];
|
||||
}
|
||||
|
||||
return chapters.Select(c => new MoveFileOrFolderJob(oldPath[c], c.FullArchiveFilePath!));
|
||||
}
|
||||
|
Reference in New Issue
Block a user