mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Logging Change (#1941)
* Tweaked trace logging for foreign constraint issue. Removed some locks where we werent touching important code that needed locking on. * Reverted back some code
This commit is contained in:
parent
201f8526f9
commit
3eb2874bbd
@ -198,7 +198,14 @@ public class ProcessSeries : IProcessSeries
|
|||||||
_logger.LogCritical(ex,
|
_logger.LogCritical(ex,
|
||||||
"[ScannerService] There was an issue writing to the database for series {SeriesName}",
|
"[ScannerService] There was an issue writing to the database for series {SeriesName}",
|
||||||
series.Name);
|
series.Name);
|
||||||
_logger.LogTrace("[ScannerService] Full Series Dump: {@Series}", series);
|
_logger.LogTrace("[ScannerService] Series Metadata Dump: {@Series}", series.Metadata);
|
||||||
|
_logger.LogTrace("[ScannerService] People Dump: {@People}", _people
|
||||||
|
.Select(p =>
|
||||||
|
new {p.Id, p.Name, SeriesMetadataIds =
|
||||||
|
p.SeriesMetadatas?.Select(m => m.Id),
|
||||||
|
ChapterMetadataIds =
|
||||||
|
p.ChapterMetadatas?.Select(m => m.Id)
|
||||||
|
.ToList()}));
|
||||||
|
|
||||||
await _eventHub.SendMessageAsync(MessageFactory.Error,
|
await _eventHub.SendMessageAsync(MessageFactory.Error,
|
||||||
MessageFactory.ErrorEvent($"There was an issue writing to the DB for Series {series}",
|
MessageFactory.ErrorEvent($"There was an issue writing to the DB for Series {series}",
|
||||||
@ -316,7 +323,6 @@ public class ProcessSeries : IProcessSeries
|
|||||||
if (!string.IsNullOrEmpty(firstChapter?.SeriesGroup) && library.ManageCollections)
|
if (!string.IsNullOrEmpty(firstChapter?.SeriesGroup) && library.ManageCollections)
|
||||||
{
|
{
|
||||||
_logger.LogDebug("Collection tag(s) found for {SeriesName}, updating collections", series.Name);
|
_logger.LogDebug("Collection tag(s) found for {SeriesName}, updating collections", series.Name);
|
||||||
|
|
||||||
foreach (var collection in firstChapter.SeriesGroup.Split(','))
|
foreach (var collection in firstChapter.SeriesGroup.Split(','))
|
||||||
{
|
{
|
||||||
var normalizedName = Parser.Parser.Normalize(collection);
|
var normalizedName = Parser.Parser.Normalize(collection);
|
||||||
@ -330,19 +336,17 @@ public class ProcessSeries : IProcessSeries
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lock (_genreLock)
|
if (!series.Metadata.GenresLocked)
|
||||||
{
|
{
|
||||||
var genres = chapters.SelectMany(c => c.Genres).ToList();
|
var genres = chapters.SelectMany(c => c.Genres).ToList();
|
||||||
GenreHelper.KeepOnlySameGenreBetweenLists(series.Metadata.Genres.ToList(), genres, genre =>
|
GenreHelper.KeepOnlySameGenreBetweenLists(series.Metadata.Genres.ToList(), genres, genre =>
|
||||||
{
|
{
|
||||||
if (series.Metadata.GenresLocked) return; // NOTE: Doesn't it make sense to do the locked skip outside this loop?
|
|
||||||
series.Metadata.Genres.Remove(genre);
|
series.Metadata.Genres.Remove(genre);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Handle People
|
// Handle People
|
||||||
lock (_peopleLock)
|
|
||||||
{
|
|
||||||
foreach (var chapter in chapters)
|
foreach (var chapter in chapters)
|
||||||
{
|
{
|
||||||
if (!series.Metadata.WriterLocked)
|
if (!series.Metadata.WriterLocked)
|
||||||
@ -479,12 +483,13 @@ public class ProcessSeries : IProcessSeries
|
|||||||
case PersonRole.Translator:
|
case PersonRole.Translator:
|
||||||
if (!series.Metadata.TranslatorLocked) series.Metadata.People.Remove(person);
|
if (!series.Metadata.TranslatorLocked) series.Metadata.People.Remove(person);
|
||||||
break;
|
break;
|
||||||
|
case PersonRole.Other:
|
||||||
default:
|
default:
|
||||||
series.Metadata.People.Remove(person);
|
series.Metadata.People.Remove(person);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateVolumes(Series series, IList<ParserInfo> parsedInfos, bool forceUpdate = false)
|
public void UpdateVolumes(Series series, IList<ParserInfo> parsedInfos, bool forceUpdate = false)
|
||||||
@ -727,18 +732,7 @@ public class ProcessSeries : IProcessSeries
|
|||||||
|
|
||||||
void AddPerson(Person person)
|
void AddPerson(Person person)
|
||||||
{
|
{
|
||||||
// TODO: Temp have code inlined to help debug foreign key constraint issue
|
PersonHelper.AddPersonIfNotExists(chapter.People, person);
|
||||||
//PersonHelper.AddPersonIfNotExists(chapter.People, person);
|
|
||||||
if (string.IsNullOrEmpty(person.Name)) return;
|
|
||||||
var existingPerson = chapter.People.FirstOrDefault(p =>
|
|
||||||
p.NormalizedName == person.Name.ToNormalized() && p.Role == person.Role);
|
|
||||||
_logger.LogTrace("[PersonHelper] Attempting to add {@Person} to {FileName} with ChapterID {ChapterId}, adding if not null: {@ExistingPerson}",
|
|
||||||
person, chapter.Files.FirstOrDefault()?.FilePath, chapter.Id, existingPerson);
|
|
||||||
|
|
||||||
if (existingPerson == null)
|
|
||||||
{
|
|
||||||
chapter.People.Add(person);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddGenre(Genre genre, bool newTag)
|
void AddGenre(Genre genre, bool newTag)
|
||||||
@ -835,14 +829,13 @@ public class ProcessSeries : IProcessSeries
|
|||||||
lock (_peopleLock)
|
lock (_peopleLock)
|
||||||
{
|
{
|
||||||
var allPeopleTypeRole = _people.Where(p => p.Role == role).ToList();
|
var allPeopleTypeRole = _people.Where(p => p.Role == role).ToList();
|
||||||
_logger.LogTrace("[UpdatePeople] for {Role} and Names of {Names}", role, names);
|
|
||||||
_logger.LogTrace("[UpdatePeople] for {Role} found {@People}", role, allPeopleTypeRole.Select(p => new {p.Id, p.Name, SeriesMetadataIds = p.SeriesMetadatas?.Select(m => m.Id).ToList()}));
|
|
||||||
|
|
||||||
foreach (var name in names)
|
foreach (var name in names)
|
||||||
{
|
{
|
||||||
var normalizedName = name.ToNormalized();
|
var normalizedName = name.ToNormalized();
|
||||||
var person = allPeopleTypeRole.FirstOrDefault(p =>
|
var person = allPeopleTypeRole.FirstOrDefault(p =>
|
||||||
p.NormalizedName != null && p.NormalizedName.Equals(normalizedName));
|
p.NormalizedName != null && p.NormalizedName.Equals(normalizedName));
|
||||||
|
_logger.LogTrace("[UpdatePeople] Checking if we can add {Name} for {Role}", names, role);
|
||||||
|
|
||||||
if (person == null)
|
if (person == null)
|
||||||
{
|
{
|
||||||
@ -850,7 +843,7 @@ public class ProcessSeries : IProcessSeries
|
|||||||
_logger.LogTrace("[UpdatePeople] for {Role} no one found, adding to _people", role);
|
_logger.LogTrace("[UpdatePeople] for {Role} no one found, adding to _people", role);
|
||||||
_people.Add(person);
|
_people.Add(person);
|
||||||
}
|
}
|
||||||
|
_logger.LogTrace("[UpdatePeople] For {Name}, found person with id: {Id}", role, person.Id);
|
||||||
action(person);
|
action(person);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user