diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/API/Controllers/SearchesController.cs | 2 | ||||
| -rw-r--r-- | src/slskd/Core/Search/SearchDbContext.cs (renamed from src/slskd/Core/DbContext.cs) | 11 | ||||
| -rw-r--r-- | src/slskd/Program.cs | 10 | ||||
| -rw-r--r-- | src/slskd/Startup.cs | 14 |
4 files changed, 22 insertions, 15 deletions
diff --git a/src/slskd/API/Controllers/SearchesController.cs b/src/slskd/API/Controllers/SearchesController.cs index 4a3dc7ab..6d322bda 100644 --- a/src/slskd/API/Controllers/SearchesController.cs +++ b/src/slskd/API/Controllers/SearchesController.cs @@ -102,7 +102,7 @@ namespace slskd.API.Controllers /// <response code="404">A matching search was not found.</response> [HttpGet("{id}")] [Authorize] - [ProducesResponseType(typeof(Search), 200)] + [ProducesResponseType(typeof(Soulseek.Search), 200)] [ProducesResponseType(404)] public IActionResult GetById([FromRoute]Guid id) { diff --git a/src/slskd/Core/DbContext.cs b/src/slskd/Core/Search/SearchDbContext.cs index ba4e50a6..4832bc17 100644 --- a/src/slskd/Core/DbContext.cs +++ b/src/slskd/Core/Search/SearchDbContext.cs @@ -1,4 +1,4 @@ -// <copyright file="DbContext.cs" company="slskd Team"> +// <copyright file="SearchDbContext.cs" company="slskd Team"> // Copyright (c) slskd Team. All rights reserved. // // This program is free software: you can redistribute it and/or modify @@ -15,18 +15,17 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd +namespace slskd.Search { using Microsoft.EntityFrameworkCore; - using slskd.Search; - public class AppDbContext : DbContext + public class SearchDbContext : DbContext { - public AppDbContext(DbContextOptions<AppDbContext> options) + public SearchDbContext(DbContextOptions<SearchDbContext> options) : base(options) { } - public DbSet<Search.Search> Searches { get; set; } + public DbSet<Search> Searches { get; set; } } } diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 7a526fb2..7ccebe6e 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -63,11 +63,6 @@ namespace slskd public static readonly string DefaultConfigurationFile = Path.Combine(AppContext.BaseDirectory, "config", $"{AppName}.yml"); /// <summary> - /// The default XML documentation filename. - /// </summary> - public static readonly string DefaultXmlDocumentationFile = Path.Combine(AppContext.BaseDirectory, "etc", $"{AppName}.xml"); - - /// <summary> /// The default incomplete download directory. /// </summary> public static readonly string DefaultIncompleteDirectory = Path.Combine(DefaultAppDirectory, "incomplete"); @@ -88,6 +83,11 @@ namespace slskd public static readonly string EnvironmentVariablePrefix = $"{AppName.ToUpperInvariant()}_"; /// <summary> + /// The default XML documentation filename. + /// </summary> + public static readonly string XmlDocumentationFile = Path.Combine(AppContext.BaseDirectory, "etc", $"{AppName}.xml"); + + /// <summary> /// Gets the assembly version of the application. /// </summary> /// <remarks> diff --git a/src/slskd/Startup.cs b/src/slskd/Startup.cs index f073117c..bd2e8963 100644 --- a/src/slskd/Startup.cs +++ b/src/slskd/Startup.cs @@ -24,6 +24,7 @@ namespace slskd using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Mvc.ApiExplorer; + using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; @@ -149,13 +150,13 @@ namespace slskd Version = "v0", }); - if (File.Exists(Program.DefaultXmlDocumentationFile)) + if (File.Exists(Program.XmlDocumentationFile)) { - options.IncludeXmlComments(Program.DefaultXmlDocumentationFile); + options.IncludeXmlComments(Program.XmlDocumentationFile); } else { - logger.Warning($"Unable to find XML documentation in {Program.DefaultXmlDocumentationFile}, Swagger will not include metadata"); + logger.Warning($"Unable to find XML documentation in {Program.XmlDocumentationFile}, Swagger will not include metadata"); } }); } @@ -165,6 +166,13 @@ namespace slskd services.AddSystemMetrics(); } + services.AddDbContextFactory<SearchDbContext>(options => + { + options.UseSqlite($"Data Source={Path.Combine(Options.Directories.App, "search.db")}"); + }); + + services.AddTransient(p => p.GetRequiredService<IDbContextFactory<SearchDbContext>>().CreateDbContext()); + services.AddSingleton<ITransferTracker, TransferTracker>(); services.AddSingleton<ISearchTracker, SearchTracker>(); services.AddSingleton<IBrowseTracker, BrowseTracker>(); |
