Skip to content

Commit

Permalink
Fixed the constraint issue with Metadata and ensure we log parameters…
Browse files Browse the repository at this point in the history
… on development modes. (#273)
  • Loading branch information
majora2007 authored Jun 6, 2021
1 parent ee3cb9e commit f0f74e8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions API/Data/LibraryRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public async Task<Library> GetFullLibraryForIdAsync(int libraryId)
.Where(x => x.Id == libraryId)
.Include(f => f.Folders)
.Include(l => l.Series)
.ThenInclude(s => s.Metadata)
.Include(l => l.Series)
.ThenInclude(s => s.Volumes)
.ThenInclude(v => v.Chapters)
.ThenInclude(c => c.Files)
Expand Down
5 changes: 4 additions & 1 deletion API/Extensions/ApplicationServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
using API.Interfaces.Services;
using API.Services;
using API.Services.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace API.Extensions
{
public static class ApplicationServiceExtensions
{
public static IServiceCollection AddApplicationServices(this IServiceCollection services, IConfiguration config)
public static IServiceCollection AddApplicationServices(this IServiceCollection services, IConfiguration config, IWebHostEnvironment env)
{
services.AddAutoMapper(typeof(AutoMapperProfiles).Assembly);
services.AddScoped<ITaskScheduler, TaskScheduler>();
Expand All @@ -32,6 +34,7 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection
services.AddDbContext<DataContext>(options =>
{
options.UseSqlite(config.GetConnectionString("DefaultConnection"));
options.EnableSensitiveDataLogging(env.IsDevelopment());
});

services.AddLogging(loggingBuilder =>
Expand Down
1 change: 1 addition & 0 deletions API/Services/Tasks/ScannerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ private void UpdateLibrary(Library library, Dictionary<string, List<ParserInfo>>

existingSeries.NormalizedName = Parser.Parser.Normalize(existingSeries.Name);
existingSeries.OriginalName ??= infos[0].Series;
existingSeries.Metadata ??= DbFactory.SeriesMetadata(new List<CollectionTag>());
}

// Now, we only have to deal with series that exist on disk. Let's recalculate the volumes for each series
Expand Down
6 changes: 4 additions & 2 deletions API/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ namespace API
public class Startup
{
private readonly IConfiguration _config;
private readonly IWebHostEnvironment _env;

public Startup(IConfiguration config)
public Startup(IConfiguration config, IWebHostEnvironment env)
{
_config = config;
_env = env;
}

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddApplicationServices(_config);
services.AddApplicationServices(_config, _env);
services.AddControllers();
services.Configure<ForwardedHeadersOptions>(options =>
{
Expand Down

0 comments on commit f0f74e8

Please sign in to comment.