mirror of
https://github.com/C9Glax/tranga.git
synced 2025-09-10 11:58:19 +02:00
Improved CancellationToken usage, Added more logging to Workers, Added Code-comments (please future me, be thankful)
This commit is contained in:
@@ -71,7 +71,11 @@ public class Chapter : Identifiable, IComparable<Chapter>
|
||||
/// Checks the filesystem if an archive at the ArchiveFilePath exists
|
||||
/// </summary>
|
||||
/// <returns>True if archive exists on disk</returns>
|
||||
public bool CheckDownloaded() => File.Exists(FullArchiveFilePath);
|
||||
public bool CheckDownloaded()
|
||||
{
|
||||
//TODO Log here
|
||||
return File.Exists(FullArchiveFilePath);
|
||||
}
|
||||
|
||||
/// Placeholders:
|
||||
/// %M Obj Name
|
||||
|
@@ -32,4 +32,6 @@ public class MetadataEntry
|
||||
this.Identifier = identifier;
|
||||
this.MetadataFetcherName = metadataFetcherName;
|
||||
}
|
||||
|
||||
public override string ToString() => $"{GetType().FullName} {MangaId} {MetadataFetcherName}";
|
||||
}
|
@@ -48,12 +48,22 @@ public class MyAnimeList : MetadataFetcher
|
||||
/// <exception cref="DbUpdateException"></exception>
|
||||
public override async Task UpdateMetadata(MetadataEntry metadataEntry, MangaContext dbContext, CancellationToken token)
|
||||
{
|
||||
if (await dbContext.Mangas.FirstOrDefaultAsync(m => m.Key == metadataEntry.MangaId, token) is not { } dbManga)
|
||||
throw new DbUpdateException("Manga not found");
|
||||
|
||||
Manga? dbManga = metadataEntry.Manga; //Might be null!
|
||||
if (dbManga is null)
|
||||
{
|
||||
if (await dbContext.Mangas.FirstOrDefaultAsync(m => m.Key == metadataEntry.MangaId, token) is not
|
||||
{ } update)
|
||||
throw new DbUpdateException("Manga not found");
|
||||
dbManga = update;
|
||||
}
|
||||
|
||||
// Load all collections (tags, links, authors)...
|
||||
foreach (CollectionEntry collectionEntry in dbContext.Entry(dbManga).Collections)
|
||||
await collectionEntry.LoadAsync(token);
|
||||
await dbContext.Entry(dbManga).Navigation(nameof(Manga.Library)).LoadAsync(token);
|
||||
{
|
||||
if(!collectionEntry.IsLoaded)
|
||||
await collectionEntry.LoadAsync(token);
|
||||
}
|
||||
await dbContext.Entry(dbManga).Reference(m => m.Library).LoadAsync(token);
|
||||
|
||||
MangaFull resultData;
|
||||
try
|
||||
|
Reference in New Issue
Block a user