mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
Autofac registrations are not singleton anymore.
This commit is contained in:
parent
3cdff3bb71
commit
f2886d89de
@ -22,12 +22,10 @@ public static void RegisterAssemblyTypes(this ContainerBuilder containerBuilder,
|
|||||||
}
|
}
|
||||||
|
|
||||||
containerBuilder.RegisterAssemblyTypes(apiAssembly)
|
containerBuilder.RegisterAssemblyTypes(apiAssembly)
|
||||||
.AsImplementedInterfaces()
|
.AsImplementedInterfaces();
|
||||||
.SingleInstance();
|
|
||||||
|
|
||||||
containerBuilder.RegisterAssemblyTypes(apiAssembly)
|
containerBuilder.RegisterAssemblyTypes(apiAssembly)
|
||||||
.AsSelf()
|
.AsSelf();
|
||||||
.SingleInstance();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -37,15 +37,15 @@ private static void RegisterAssembly(this ContainerBuilder container, string ass
|
|||||||
|
|
||||||
container.RegisterAssemblyTypes(assembly)
|
container.RegisterAssemblyTypes(assembly)
|
||||||
.Where(t => t.IsSubclassOf(typeof(IndexerBase)))
|
.Where(t => t.IsSubclassOf(typeof(IndexerBase)))
|
||||||
.As<IndexerBase>().SingleInstance();
|
.As<IndexerBase>();
|
||||||
|
|
||||||
container.RegisterAssemblyTypes(assembly)
|
container.RegisterAssemblyTypes(assembly)
|
||||||
.Where(t => t.IsSubclassOf(typeof(IndexerSearchBase)))
|
.Where(t => t.IsSubclassOf(typeof(IndexerSearchBase)))
|
||||||
.As<IndexerSearchBase>().SingleInstance();
|
.As<IndexerSearchBase>();
|
||||||
|
|
||||||
container.RegisterAssemblyTypes(assembly)
|
container.RegisterAssemblyTypes(assembly)
|
||||||
.Where(t => t.IsSubclassOf(typeof(ExternalNotificationBase)))
|
.Where(t => t.IsSubclassOf(typeof(ExternalNotificationBase)))
|
||||||
.As<ExternalNotificationBase>().SingleInstance();
|
.As<ExternalNotificationBase>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void InitDatabase(this ContainerBuilder container)
|
private static void InitDatabase(this ContainerBuilder container)
|
||||||
@ -56,7 +56,7 @@ private static void InitDatabase(this ContainerBuilder container)
|
|||||||
var appDataPath = environmentProvider.GetAppDataPath();
|
var appDataPath = environmentProvider.GetAppDataPath();
|
||||||
if (!Directory.Exists(appDataPath)) Directory.CreateDirectory(appDataPath);
|
if (!Directory.Exists(appDataPath)) Directory.CreateDirectory(appDataPath);
|
||||||
|
|
||||||
container.Register(c => c.Resolve<IDbFactory>().Create(environmentProvider.GetNzbDroneDatabase())).As<IDatabase>().SingleInstance();
|
container.Register(c => c.Resolve<IDbFactory>().Create(environmentProvider.GetNzbDroneDatabase())).As<IDatabase>();
|
||||||
|
|
||||||
container.RegisterGeneric(typeof(BasicRepository<>)).As(typeof(IBasicRepository<>));
|
container.RegisterGeneric(typeof(BasicRepository<>)).As(typeof(IBasicRepository<>));
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Data;
|
|
||||||
using System.Data.SQLite;
|
using System.Data.SQLite;
|
||||||
using Marr.Data;
|
using Marr.Data;
|
||||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
@ -16,9 +15,13 @@ public class DbFactory : IDbFactory
|
|||||||
{
|
{
|
||||||
private readonly IMigrationController _migrationController;
|
private readonly IMigrationController _migrationController;
|
||||||
|
|
||||||
public DbFactory(IMigrationController migrationController)
|
static DbFactory()
|
||||||
{
|
{
|
||||||
TableMapping.Map();
|
TableMapping.Map();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DbFactory(IMigrationController migrationController)
|
||||||
|
{
|
||||||
_migrationController = migrationController;
|
_migrationController = migrationController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using System.Reflection;
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
using FluentMigrator.Runner;
|
using FluentMigrator.Runner;
|
||||||
using FluentMigrator.Runner.Initialization;
|
using FluentMigrator.Runner.Initialization;
|
||||||
using FluentMigrator.Runner.Processors.Sqlite;
|
using FluentMigrator.Runner.Processors.Sqlite;
|
||||||
@ -14,6 +16,8 @@ public class MigrationController : IMigrationController
|
|||||||
{
|
{
|
||||||
private readonly IAnnouncer _announcer;
|
private readonly IAnnouncer _announcer;
|
||||||
|
|
||||||
|
private static readonly HashSet<string> MigrationCache = new HashSet<string>();
|
||||||
|
|
||||||
public MigrationController(IAnnouncer announcer)
|
public MigrationController(IAnnouncer announcer)
|
||||||
{
|
{
|
||||||
_announcer = announcer;
|
_announcer = announcer;
|
||||||
@ -21,6 +25,10 @@ public MigrationController(IAnnouncer announcer)
|
|||||||
|
|
||||||
public void MigrateToLatest(string connectionString, MigrationType migrationType)
|
public void MigrateToLatest(string connectionString, MigrationType migrationType)
|
||||||
{
|
{
|
||||||
|
lock (MigrationCache)
|
||||||
|
{
|
||||||
|
if (MigrationCache.Contains(connectionString.ToLower())) return;
|
||||||
|
|
||||||
var assembly = Assembly.GetExecutingAssembly();
|
var assembly = Assembly.GetExecutingAssembly();
|
||||||
|
|
||||||
var migrationContext = new RunnerContext(_announcer)
|
var migrationContext = new RunnerContext(_announcer)
|
||||||
@ -34,6 +42,9 @@ public void MigrateToLatest(string connectionString, MigrationType migrationType
|
|||||||
var processor = factory.Create(connectionString, _announcer, options);
|
var processor = factory.Create(connectionString, _announcer, options);
|
||||||
var runner = new MigrationRunner(assembly, migrationContext, processor);
|
var runner = new MigrationRunner(assembly, migrationContext, processor);
|
||||||
runner.MigrateUp(true);
|
runner.MigrateUp(true);
|
||||||
|
|
||||||
|
MigrationCache.Add(connectionString.ToLower());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
|
Loading…
Reference in New Issue
Block a user