mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-30 19:54:14 -04:00
* Expand the list of potential favicon icons to grab. * Added a url mapping functionality to use alternative urls for fetching icons * Initial commit to streamline media encoding. No DB migration yet, No UI changes, no Task changes. * Started refactoring code so that webp queries use encoding format instead. * More refactoring to remove hardcoded webp references. * Moved manual migrations to their own folder to keep things organized. Manually drop the obsolete webp keys. * Removed old apis for converting media and now have one. Reworked where the conversion code was located and streamlined events and whatnot. * Make favicon encode setting aware * Cleaned up favicon conversion * Updated format counter to now just use Extension from MangaFile now that it's been out a while. * Tweaked jumpbar code to reduce a lookup to hashmap. * Added AVIF (8-bit only) support. * In UpdatePeopleList, use FirstOrDefault as Single adds extra checks that may not be needed. * You can now remove weblinks from edit series page and you can leave empty cells, they will just be removed on backend. * Forgot a file * Don't prompt to write a review, just show the pencil. It's the same amount of clicks if you do, less if you dont. * Fixed Refresh token using wrong Claim to look up the user. * Refactored how we refresh authentication to perform it every 10 m ins to ensure we always stay authenticated. * Changed Version update code to run more throughout the day. Updated some hangfire to newer method signatures.
119 lines
4.7 KiB
C#
119 lines
4.7 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace API.Data.ManualMigrations;
|
|
|
|
/// <summary>
|
|
/// v0.6.0 introduced a change in how Normalization works and hence every normalized field needs to be re-calculated
|
|
/// </summary>
|
|
public static class MigrateNormalizedEverything
|
|
{
|
|
public static async Task Migrate(IUnitOfWork unitOfWork, DataContext dataContext, ILogger<Program> logger)
|
|
{
|
|
// if current version is > 0.5.6.5, then we can exit and not perform
|
|
var settings = await unitOfWork.SettingsRepository.GetSettingsDtoAsync();
|
|
if (Version.Parse(settings.InstallVersion) > new Version(0, 5, 6, 5))
|
|
{
|
|
return;
|
|
}
|
|
logger.LogCritical("Running MigrateNormalizedEverything migration. Please be patient, this may take some time depending on the size of your library. Do not abort, this can break your Database");
|
|
|
|
logger.LogInformation("Updating Normalization on Series...");
|
|
foreach (var series in await dataContext.Series.ToListAsync())
|
|
{
|
|
series.NormalizedLocalizedName = Services.Tasks.Scanner.Parser.Parser.Normalize(series.LocalizedName ?? string.Empty);
|
|
series.NormalizedName = Services.Tasks.Scanner.Parser.Parser.Normalize(series.Name ?? string.Empty);
|
|
logger.LogInformation("Updated Series: {SeriesName}", series.Name);
|
|
unitOfWork.SeriesRepository.Update(series);
|
|
}
|
|
|
|
if (unitOfWork.HasChanges())
|
|
{
|
|
await unitOfWork.CommitAsync();
|
|
}
|
|
logger.LogInformation("Updating Normalization on Series...Done");
|
|
|
|
// Genres
|
|
logger.LogInformation("Updating Normalization on Genres...");
|
|
foreach (var genre in await dataContext.Genre.ToListAsync())
|
|
{
|
|
genre.NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(genre.Title ?? string.Empty);
|
|
logger.LogInformation("Updated Genre: {Genre}", genre.Title);
|
|
unitOfWork.GenreRepository.Attach(genre);
|
|
}
|
|
|
|
if (unitOfWork.HasChanges())
|
|
{
|
|
await unitOfWork.CommitAsync();
|
|
}
|
|
logger.LogInformation("Updating Normalization on Genres...Done");
|
|
|
|
// Tags
|
|
logger.LogInformation("Updating Normalization on Tags...");
|
|
foreach (var tag in await dataContext.Tag.ToListAsync())
|
|
{
|
|
tag.NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(tag.Title ?? string.Empty);
|
|
logger.LogInformation("Updated Tag: {Tag}", tag.Title);
|
|
unitOfWork.TagRepository.Attach(tag);
|
|
}
|
|
|
|
if (unitOfWork.HasChanges())
|
|
{
|
|
await unitOfWork.CommitAsync();
|
|
}
|
|
logger.LogInformation("Updating Normalization on Tags...Done");
|
|
|
|
// People
|
|
logger.LogInformation("Updating Normalization on People...");
|
|
foreach (var person in await dataContext.Person.ToListAsync())
|
|
{
|
|
person.NormalizedName = Services.Tasks.Scanner.Parser.Parser.Normalize(person.Name ?? string.Empty);
|
|
logger.LogInformation("Updated Person: {Person}", person.Name);
|
|
unitOfWork.PersonRepository.Attach(person);
|
|
}
|
|
|
|
if (unitOfWork.HasChanges())
|
|
{
|
|
await unitOfWork.CommitAsync();
|
|
}
|
|
logger.LogInformation("Updating Normalization on People...Done");
|
|
|
|
// Collections
|
|
logger.LogInformation("Updating Normalization on Collections...");
|
|
foreach (var collection in await dataContext.CollectionTag.ToListAsync())
|
|
{
|
|
collection.NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(collection.Title ?? string.Empty);
|
|
logger.LogInformation("Updated Collection: {Collection}", collection.Title);
|
|
unitOfWork.CollectionTagRepository.Update(collection);
|
|
}
|
|
|
|
if (unitOfWork.HasChanges())
|
|
{
|
|
await unitOfWork.CommitAsync();
|
|
}
|
|
logger.LogInformation("Updating Normalization on Collections...Done");
|
|
|
|
// Reading Lists
|
|
logger.LogInformation("Updating Normalization on Reading Lists...");
|
|
foreach (var readingList in await dataContext.ReadingList.ToListAsync())
|
|
{
|
|
readingList.NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(readingList.Title ?? string.Empty);
|
|
logger.LogInformation("Updated Reading List: {ReadingList}", readingList.Title);
|
|
unitOfWork.ReadingListRepository.Update(readingList);
|
|
}
|
|
|
|
if (unitOfWork.HasChanges())
|
|
{
|
|
await unitOfWork.CommitAsync();
|
|
}
|
|
logger.LogInformation("Updating Normalization on Reading Lists...Done");
|
|
|
|
|
|
logger.LogInformation("MigrateNormalizedEverything migration finished");
|
|
|
|
}
|
|
|
|
}
|