From 117bd1cd8b14a5d93c495139918631a30ca1d3f4 Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Tue, 26 Mar 2019 12:12:58 +0000 Subject: [PATCH] #2750 stuff --- .../Authentication/OmbiUserManager.cs | 2 +- src/Ombi.DependencyInjection/IocExtensions.cs | 36 +++++++++---------- src/Ombi.Store/Context/OmbiContext.cs | 1 + src/Ombi/Startup.cs | 3 -- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/Ombi.Core/Authentication/OmbiUserManager.cs b/src/Ombi.Core/Authentication/OmbiUserManager.cs index 2c78f39bf..6155672b3 100644 --- a/src/Ombi.Core/Authentication/OmbiUserManager.cs +++ b/src/Ombi.Core/Authentication/OmbiUserManager.cs @@ -158,7 +158,7 @@ namespace Ombi.Core.Authentication if (!email.Equals(result.User?.Email)) { user.Email = result.User?.Email; - await UpdateAsync(user); + await GlobalMutex.Lock(async () => await UpdateAsync(user)); } return true; diff --git a/src/Ombi.DependencyInjection/IocExtensions.cs b/src/Ombi.DependencyInjection/IocExtensions.cs index 69e6bd3ca..466b74bb0 100644 --- a/src/Ombi.DependencyInjection/IocExtensions.cs +++ b/src/Ombi.DependencyInjection/IocExtensions.cs @@ -134,28 +134,28 @@ namespace Ombi.DependencyInjection } public static void RegisterStore(this IServiceCollection services) { - services.AddEntityFrameworkSqlite().AddDbContext(); - services.AddEntityFrameworkSqlite().AddDbContext(); - services.AddEntityFrameworkSqlite().AddDbContext(); + services.AddDbContext(); + services.AddDbContext(); + services.AddDbContext(); services.AddScoped(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6 services.AddScoped(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6 services.AddScoped(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6 - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(typeof(ISettingsService<>), typeof(SettingsService<>)); - services.AddTransient(typeof(IRepository<>), typeof(Repository<>)); - services.AddTransient(typeof(IExternalRepository<>), typeof(ExternalRepository<>)); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(typeof(ISettingsService<>), typeof(SettingsService<>)); + services.AddScoped(typeof(IRepository<>), typeof(Repository<>)); + services.AddScoped(typeof(IExternalRepository<>), typeof(ExternalRepository<>)); } public static void RegisterServices(this IServiceCollection services) { @@ -163,7 +163,7 @@ namespace Ombi.DependencyInjection services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddSingleton(); services.AddTransient(); services.AddTransient(); diff --git a/src/Ombi.Store/Context/OmbiContext.cs b/src/Ombi.Store/Context/OmbiContext.cs index 2f19bc681..98f4cd9c3 100644 --- a/src/Ombi.Store/Context/OmbiContext.cs +++ b/src/Ombi.Store/Context/OmbiContext.cs @@ -17,6 +17,7 @@ namespace Ombi.Store.Context { if (_created) return; + _created = true; Database.SetCommandTimeout(60); Database.Migrate(); diff --git a/src/Ombi/Startup.cs b/src/Ombi/Startup.cs index bbf56c517..fa70df147 100644 --- a/src/Ombi/Startup.cs +++ b/src/Ombi/Startup.cs @@ -56,9 +56,6 @@ namespace Ombi // This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { - // Add framework services. - services.AddDbContext(); - services.AddIdentity() .AddEntityFrameworkStores() .AddDefaultTokenProviders()