Lots of Bugfixes (#2960)
Co-authored-by: Samuel Martins <s@smartins.ch> Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
This commit is contained in:
parent
97ffdd0975
commit
b50fa0fd1e
45 changed files with 563 additions and 282 deletions
48
API/Data/ManualMigrations/ManualMigrateSwitchToWal.cs
Normal file
48
API/Data/ManualMigrations/ManualMigrateSwitchToWal.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using API.Entities;
|
||||
using Kavita.Common.EnvironmentInfo;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace API.Data.ManualMigrations;
|
||||
|
||||
/// <summary>
|
||||
/// v0.8.2 switches Default Kavita installs to WAL
|
||||
/// </summary>
|
||||
public static class ManualMigrateSwitchToWal
|
||||
{
|
||||
public static async Task Migrate(DataContext context, ILogger<Program> logger)
|
||||
{
|
||||
if (await context.ManualMigrationHistory.AnyAsync(m => m.Name == "ManualMigrateSwitchToWal"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
logger.LogCritical("Running ManualMigrateSwitchToWal migration - Please be patient, this may take some time. This is not an error");
|
||||
try
|
||||
{
|
||||
var connection = context.Database.GetDbConnection();
|
||||
await connection.OpenAsync();
|
||||
await using var command = connection.CreateCommand();
|
||||
command.CommandText = "PRAGMA journal_mode=WAL;";
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Error setting WAL");
|
||||
/* Swallow */
|
||||
}
|
||||
|
||||
await context.ManualMigrationHistory.AddAsync(new ManualMigrationHistory()
|
||||
{
|
||||
Name = "ManualMigrateSwitchToWal",
|
||||
ProductVersion = BuildInfo.Version.ToString(),
|
||||
RanAt = DateTime.UtcNow
|
||||
});
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
logger.LogCritical("Running ManualMigrateSwitchToWal migration - Completed. This is not an error");
|
||||
}
|
||||
|
||||
}
|
49
API/Data/ManualMigrations/ManualMigrateThemeDescription.cs
Normal file
49
API/Data/ManualMigrations/ManualMigrateThemeDescription.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.Entities;
|
||||
using Kavita.Common.EnvironmentInfo;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace API.Data.ManualMigrations;
|
||||
|
||||
/// <summary>
|
||||
/// v0.8.2 introduced Theme repo viewer, this adds Description to existing SiteTheme defaults
|
||||
/// </summary>
|
||||
public static class ManualMigrateThemeDescription
|
||||
{
|
||||
public static async Task Migrate(DataContext context, ILogger<Program> logger)
|
||||
{
|
||||
if (await context.ManualMigrationHistory.AnyAsync(m => m.Name == "ManualMigrateThemeDescription"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
logger.LogCritical("Running ManualMigrateThemeDescription migration - Please be patient, this may take some time. This is not an error");
|
||||
|
||||
var theme = await context.SiteTheme.FirstOrDefaultAsync(t => t.Name == "Dark");
|
||||
if (theme != null)
|
||||
{
|
||||
theme.Description = Seed.DefaultThemes.First().Description;
|
||||
}
|
||||
|
||||
if (context.ChangeTracker.HasChanges())
|
||||
{
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
await context.ManualMigrationHistory.AddAsync(new ManualMigrationHistory()
|
||||
{
|
||||
Name = "ManualMigrateThemeDescription",
|
||||
ProductVersion = BuildInfo.Version.ToString(),
|
||||
RanAt = DateTime.UtcNow
|
||||
});
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
logger.LogCritical("Running ManualMigrateThemeDescription migration - Completed. This is not an error");
|
||||
}
|
||||
}
|
|
@ -1748,12 +1748,12 @@ public class SeriesRepository : ISeriesRepository
|
|||
{
|
||||
// This is due to v0.5.6 introducing bugs where we could have multiple series get duplicated and no way to delete them
|
||||
// This here will delete the 2nd one as the first is the one to likely be used.
|
||||
var sId = _context.Series
|
||||
var sId = await _context.Series
|
||||
.Where(s => s.Format == parsedSeries.Format && s.NormalizedName == parsedSeries.NormalizedName &&
|
||||
s.LibraryId == libraryId)
|
||||
.Select(s => s.Id)
|
||||
.OrderBy(s => s)
|
||||
.Last();
|
||||
.LastAsync();
|
||||
if (sId > 0)
|
||||
{
|
||||
ids.Add(sId);
|
||||
|
|
|
@ -35,6 +35,7 @@ public static class Seed
|
|||
Provider = ThemeProvider.System,
|
||||
FileName = "dark.scss",
|
||||
IsDefault = true,
|
||||
Description = "Default theme shipped with Kavita"
|
||||
}
|
||||
}.ToArray()
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue