Sync logging

This commit is contained in:
2025-09-18 01:53:05 +02:00
parent d9a1923a3c
commit 9b0b5f0860
2 changed files with 6 additions and 2 deletions

View File

@@ -24,14 +24,16 @@ public abstract class TrangaBaseContext<T> : DbContext where T : DbContext
internal async Task<(bool success, string? exceptionMessage)> Sync(CancellationToken token)
{
Log.Debug($"Syncing {GetType().Name}...");
try
{
await this.SaveChangesAsync(token);
int changedRows = await this.SaveChangesAsync(token);
Log.Debug($"Synced {changedRows} rows...");
return (true, null);
}
catch (Exception e)
{
Log.Error(null, e);
Log.Error("Sync failed:", e);
return (false, e.Message);
}
}

View File

@@ -24,6 +24,8 @@ public class CleanupMangaconnectorIdsWithoutConnector : BaseWorkerWithContext<Ma
}
int deletedMangaIds = await DbContext.MangaConnectorToManga.Where(mcId => connectorNames.All(name => name != mcId.MangaConnectorName)).ExecuteDeleteAsync(CancellationToken);
Log.Info($"Deleted {deletedMangaIds} mangaIds.");
await DbContext.SaveChangesAsync(CancellationToken);
return [];
}
}