Skip to content

Commit

Permalink
Fixing folder structure issues #1745
Browse files Browse the repository at this point in the history
  • Loading branch information
mregni committed May 27, 2022
1 parent bb43882 commit dcbfec6
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 19 deletions.
3 changes: 1 addition & 2 deletions EmbyStat.Core/DataStore/EsDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public EsDbContext(DbContextOptions<EsDbContext> options): base(options)

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.EnableDetailedErrors();
optionsBuilder.UseSqlite("Data Source=SqliteData.db", x => x.MigrationsAssembly("EmbyStat.Migrations"));

}


Expand Down
9 changes: 6 additions & 3 deletions EmbyStat.Core/DataStore/SqliteBootstrap.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using Microsoft.Data.Sqlite;
using EmbyStat.Configuration.Interfaces;
using Microsoft.Data.Sqlite;

namespace EmbyStat.Core.DataStore;

public class SqliteBootstrap : ISqliteBootstrap
{
private readonly string _connectionString;
public SqliteBootstrap()
public SqliteBootstrap(IConfigurationService configurationService)
{
_connectionString = "Data Source=SqliteData.db";
var config = configurationService.Get();
var path = Path.Combine(config.SystemConfig.Dirs.Data, "SqliteData.db");
_connectionString = $"Data Source={path}";
}


Expand Down
13 changes: 10 additions & 3 deletions EmbyStat.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ private static ApplicationModes GetApplicationMode()

private static IHost BuildConsoleHost(StartupOptions options)
{
CreateFolder("config");
GenerateDefaultConfiguration();

var memoryConfig = options.ToKeyValuePairs();
Expand All @@ -151,6 +152,9 @@ private static IHost BuildConsoleHost(StartupOptions options)

var config = configurationRoot.Get<Config>();

CreateFolder(config.SystemConfig.Dirs.Logs);
CreateFolder(config.SystemConfig.Dirs.Data);

SetupLogger(config.SystemConfig.Dirs.Logs, options.LogLevel ?? 2);
LogStartupParameters(config, options.LogLevel ?? 2, options.RunAsService ?? false);

Expand Down Expand Up @@ -209,14 +213,17 @@ private static IHost BuildConsoleHost(StartupOptions options)
.Build();
}

private static void GenerateDefaultConfiguration()
private static void CreateFolder(string folder)
{
var dir = Path.Combine(Directory.GetCurrentDirectory(), "config");
var dir = Path.Combine(Directory.GetCurrentDirectory(), folder);
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}

}

private static void GenerateDefaultConfiguration()
{
var path = Path.Combine(Directory.GetCurrentDirectory(),"config", "config.json");
if (!File.Exists(path))
{
Expand Down
9 changes: 6 additions & 3 deletions EmbyStat.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using EmbyStat.Clients.Base;
using EmbyStat.Clients.Base.Api;
using EmbyStat.Common;
using EmbyStat.Common.Enums;
using EmbyStat.Common.Exceptions;
using EmbyStat.Common.Extensions;
using EmbyStat.Common.Models.Entities;
Expand Down Expand Up @@ -121,7 +120,6 @@ public void ConfigureServices(IServiceCollection services)

ConfigureRollbarInfrastructure();


services.AddRollbarLogger(loggerOptions =>
{
loggerOptions.Filter = loggerOptions.Filter = (_, loglevel) => loglevel >= LogLevel.Error;
Expand All @@ -133,7 +131,12 @@ public void ConfigureServices(IServiceCollection services)
});

services.AddSignalR();
services.AddDbContext<EsDbContext>();
var dbPath = Path.Combine(configuration.SystemConfig.Dirs.Data, "SqliteData.db");
services.AddDbContext<EsDbContext>(options =>
{
options.EnableDetailedErrors();
options.UseSqlite($"Data Source={dbPath}", x => x.MigrationsAssembly("EmbyStat.Migrations"));
});

services.AddAuthorization(options =>
{
Expand Down
1 change: 0 additions & 1 deletion Tests.Unit/Controllers/JobControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using EmbyStat.Controllers;
using EmbyStat.Controllers.Job;
using EmbyStat.Core.Jobs.Interfaces;
using EmbyStat.Core.Rollbar.Interfaces;
using EmbyStat.Jobs;
using FluentAssertions;
using Hangfire;
Expand Down
1 change: 0 additions & 1 deletion Tests.Unit/Controllers/SettingsControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using EmbyStat.Common.Models.Entities;
using EmbyStat.Controllers.Settings;
using EmbyStat.Core.Languages.Interfaces;
using EmbyStat.Core.Rollbar.Interfaces;
using FluentAssertions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
Expand Down
1 change: 0 additions & 1 deletion Tests.Unit/Services/AccountServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using EmbyStat.Common.Models.Account;
using EmbyStat.Common.Models.Entities;
using EmbyStat.Core.Account;
using EmbyStat.Core.Rollbar.Interfaces;
using FluentAssertions;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
Expand Down
1 change: 0 additions & 1 deletion Tests.Unit/Services/LogServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using EmbyStat.Common.Models.Entities;
using EmbyStat.Core.Logs;
using EmbyStat.Core.MediaServers.Interfaces;
using EmbyStat.Core.Rollbar.Interfaces;
using FluentAssertions;
using Moq;
using Xunit;
Expand Down
1 change: 0 additions & 1 deletion Tests.Unit/Services/MediaServerServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using EmbyStat.Core.Jobs.Interfaces;
using EmbyStat.Core.MediaServers;
using EmbyStat.Core.MediaServers.Interfaces;
using EmbyStat.Core.Rollbar.Interfaces;
using EmbyStat.Core.Sessions.Interfaces;
using EmbyStat.Core.Statistics.Interfaces;
using FluentAssertions;
Expand Down
1 change: 0 additions & 1 deletion Tests.Unit/Services/MovieServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using EmbyStat.Core.MediaServers.Interfaces;
using EmbyStat.Core.Movies;
using EmbyStat.Core.Movies.Interfaces;
using EmbyStat.Core.Rollbar.Interfaces;
using EmbyStat.Core.Statistics.Interfaces;
using FluentAssertions;
using Microsoft.Extensions.Logging;
Expand Down
1 change: 0 additions & 1 deletion Tests.Unit/Services/SettingsServiceTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.IO;
using EmbyStat.Core.Rollbar;
using FluentAssertions;
using Microsoft.Extensions.Options;
using Moq;
Expand Down
1 change: 0 additions & 1 deletion Tests.Unit/Services/SystemServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using EmbyStat.Core.MediaServers.Interfaces;
using EmbyStat.Core.Movies.Interfaces;
using EmbyStat.Core.People.Interfaces;
using EmbyStat.Core.Rollbar.Interfaces;
using EmbyStat.Core.Shows.Interfaces;
using EmbyStat.Core.Statistics.Interfaces;
using EmbyStat.Core.System;
Expand Down

0 comments on commit dcbfec6

Please sign in to comment.