mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
The settings have now been split out of the main db.
Next is the External stuff e.g. Plex/Emby/Sonarr/Radarr stuff
This commit is contained in:
parent
66af499970
commit
618ee16d9d
17 changed files with 328 additions and 69 deletions
|
@ -26,7 +26,7 @@ namespace Ombi.Api.Notifications
|
|||
{
|
||||
return null;
|
||||
}
|
||||
var id = await _appConfig.Get(ConfigurationTypes.Notification);
|
||||
var id = await _appConfig.GetAsync(ConfigurationTypes.Notification);
|
||||
var request = new Request(string.Empty, ApiUrl, HttpMethod.Post);
|
||||
|
||||
var body = new OneSignalNotificationBody
|
||||
|
|
|
@ -128,8 +128,10 @@ namespace Ombi.DependencyInjection
|
|||
|
||||
public static void RegisterStore(this IServiceCollection services) {
|
||||
services.AddEntityFrameworkSqlite().AddDbContext<OmbiContext>();
|
||||
services.AddEntityFrameworkSqlite().AddDbContext<SettingsContext>();
|
||||
|
||||
services.AddScoped<IOmbiContext, OmbiContext>(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6
|
||||
services.AddScoped<ISettingsContext, SettingsContext>(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6
|
||||
services.AddTransient<ISettingsRepository, SettingsJsonRepository>();
|
||||
services.AddTransient<ISettingsResolver, SettingsResolver>();
|
||||
services.AddTransient<IPlexContentRepository, PlexServerContentRepository>();
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
public class OmbiAutomaticUpdater : IOmbiAutomaticUpdater
|
||||
{
|
||||
public OmbiAutomaticUpdater(ILogger<OmbiAutomaticUpdater> log, IChangeLogProcessor service,
|
||||
ISettingsService<UpdateSettings> s, IProcessProvider proc, IRepository<ApplicationConfiguration> appConfig)
|
||||
ISettingsService<UpdateSettings> s, IProcessProvider proc, IApplicationConfigRepository appConfig)
|
||||
{
|
||||
Logger = log;
|
||||
Processor = service;
|
||||
|
@ -48,7 +48,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
private ISettingsService<UpdateSettings> Settings { get; }
|
||||
private readonly IProcessProvider _processProvider;
|
||||
private static PerformContext Ctx { get; set; }
|
||||
private readonly IRepository<ApplicationConfiguration> _appConfig;
|
||||
private readonly IApplicationConfigRepository _appConfig;
|
||||
|
||||
public string[] GetVersion()
|
||||
{
|
||||
|
@ -252,9 +252,8 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
|
||||
private string GetArgs(UpdateSettings settings)
|
||||
{
|
||||
var config = _appConfig.GetAll();
|
||||
var url = config.FirstOrDefault(x => x.Type == ConfigurationTypes.Url);
|
||||
var storage = config.FirstOrDefault(x => x.Type == ConfigurationTypes.StoragePath);
|
||||
var url = _appConfig.Get(ConfigurationTypes.Url);
|
||||
var storage = _appConfig.Get(ConfigurationTypes.StoragePath);
|
||||
|
||||
var currentLocation = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||
var processName = (settings.ProcessName.HasValue() ? settings.ProcessName : "Ombi");
|
||||
|
@ -345,7 +344,6 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
|
||||
if (disposing)
|
||||
{
|
||||
_appConfig?.Dispose();
|
||||
Settings?.Dispose();
|
||||
}
|
||||
_disposed = true;
|
||||
|
|
22
src/Ombi.Store/Context/IDbContext.cs
Normal file
22
src/Ombi.Store/Context/IDbContext.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
namespace Ombi.Store.Context
|
||||
{
|
||||
public interface IDbContext : IDisposable
|
||||
{
|
||||
EntityEntry Update(object entity);
|
||||
EntityEntry<TEntity> Update<TEntity>(TEntity entity) where TEntity : class;
|
||||
int SaveChanges();
|
||||
void Seed();
|
||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken));
|
||||
DatabaseFacade Database { get; }
|
||||
EntityEntry<T> Entry<T>(T entry) where T : class;
|
||||
EntityEntry<TEntity> Attach<TEntity>(TEntity entity) where TEntity : class;
|
||||
DbSet<TEntity> Set<TEntity>() where TEntity : class;
|
||||
}
|
||||
}
|
|
@ -9,23 +9,17 @@ using Ombi.Store.Entities.Requests;
|
|||
|
||||
namespace Ombi.Store.Context
|
||||
{
|
||||
public interface IOmbiContext : IDisposable
|
||||
public interface IOmbiContext : IDbContext
|
||||
{
|
||||
int SaveChanges();
|
||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken));
|
||||
DbSet<GlobalSettings> Settings { get; set; }
|
||||
|
||||
DbSet<PlexServerContent> PlexServerContent { get; set; }
|
||||
DbSet<PlexEpisode> PlexEpisode { get; set; }
|
||||
DbSet<GlobalSettings> Settings { get; set; }
|
||||
DbSet<RadarrCache> RadarrCache { get; set; }
|
||||
DbSet<EmbyContent> EmbyContent { get; set; }
|
||||
DbSet<EmbyEpisode> EmbyEpisode { get; set; }
|
||||
DatabaseFacade Database { get; }
|
||||
EntityEntry<T> Entry<T>(T entry) where T : class;
|
||||
EntityEntry<TEntity> Attach<TEntity>(TEntity entity) where TEntity : class;
|
||||
DbSet<TEntity> Set<TEntity>() where TEntity : class;
|
||||
DbSet<NotificationTemplates> NotificationTemplates { get; set; }
|
||||
DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||
void Seed();
|
||||
DbSet<Audit> Audit { get; set; }
|
||||
DbSet<MovieRequests> MovieRequests { get; set; }
|
||||
DbSet<AlbumRequest> AlbumRequests { get; set; }
|
||||
|
@ -36,8 +30,6 @@ namespace Ombi.Store.Context
|
|||
DbSet<Tokens> Tokens { get; set; }
|
||||
DbSet<SonarrCache> SonarrCache { get; set; }
|
||||
DbSet<SonarrEpisodeCache> SonarrEpisodeCache { get; set; }
|
||||
EntityEntry Update(object entity);
|
||||
EntityEntry<TEntity> Update<TEntity>(TEntity entity) where TEntity : class;
|
||||
DbSet<CouchPotatoCache> CouchPotatoCache { get; set; }
|
||||
DbSet<SickRageCache> SickRageCache { get; set; }
|
||||
DbSet<LidarrArtistCache> LidarrArtistCache { get; set; }
|
||||
|
|
11
src/Ombi.Store/Context/ISettingsContext.cs
Normal file
11
src/Ombi.Store/Context/ISettingsContext.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Context
|
||||
{
|
||||
public interface ISettingsContext : IDbContext
|
||||
{
|
||||
DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||
DbSet<GlobalSettings> Settings { get; set; }
|
||||
}
|
||||
}
|
|
@ -22,9 +22,10 @@ namespace Ombi.Store.Context
|
|||
}
|
||||
|
||||
public DbSet<NotificationTemplates> NotificationTemplates { get; set; }
|
||||
public DbSet<GlobalSettings> Settings { get; set; }
|
||||
public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||
public DbSet<PlexServerContent> PlexServerContent { get; set; }
|
||||
public DbSet<PlexEpisode> PlexEpisode { get; set; }
|
||||
public DbSet<GlobalSettings> Settings { get; set; }
|
||||
public DbSet<RadarrCache> RadarrCache { get; set; }
|
||||
public DbSet<CouchPotatoCache> CouchPotatoCache { get; set; }
|
||||
public DbSet<EmbyContent> EmbyContent { get; set; }
|
||||
|
@ -53,7 +54,6 @@ namespace Ombi.Store.Context
|
|||
public DbSet<RequestSubscription> RequestSubscription { get; set; }
|
||||
public DbSet<UserNotificationPreferences> UserNotificationPreferences { get; set; }
|
||||
public DbSet<UserQualityProfiles> UserQualityProfileses { get; set; }
|
||||
public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
|
@ -84,39 +84,6 @@ namespace Ombi.Store.Context
|
|||
|
||||
public void Seed()
|
||||
{
|
||||
|
||||
// Add the tokens
|
||||
var fanArt = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
|
||||
if (fanArt == null)
|
||||
{
|
||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||
{
|
||||
Type = ConfigurationTypes.FanartTv,
|
||||
Value = "4b6d983efa54d8f45c68432521335f15"
|
||||
});
|
||||
SaveChanges();
|
||||
}
|
||||
var movieDb = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
|
||||
if (movieDb == null)
|
||||
{
|
||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||
{
|
||||
Type = ConfigurationTypes.TheMovieDb,
|
||||
Value = "b8eabaf5608b88d0298aa189dd90bf00"
|
||||
});
|
||||
SaveChanges();
|
||||
}
|
||||
var notification = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Notification);
|
||||
if (notification == null)
|
||||
{
|
||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||
{
|
||||
Type = ConfigurationTypes.Notification,
|
||||
Value = "4f0260c4-9c3d-41ab-8d68-27cb5a593f0e"
|
||||
});
|
||||
SaveChanges();
|
||||
}
|
||||
|
||||
// VACUUM;
|
||||
Database.ExecuteSqlCommand("VACUUM;");
|
||||
|
||||
|
|
70
src/Ombi.Store/Context/SettingsContext.cs
Normal file
70
src/Ombi.Store/Context/SettingsContext.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Context
|
||||
{
|
||||
public sealed class SettingsContext : DbContext, ISettingsContext
|
||||
{
|
||||
private static bool _created;
|
||||
public SettingsContext()
|
||||
{
|
||||
if (_created) return;
|
||||
|
||||
_created = true;
|
||||
Database.Migrate();
|
||||
}
|
||||
|
||||
public DbSet<GlobalSettings> Settings { get; set; }
|
||||
public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
var i = StoragePathSingleton.Instance;
|
||||
if (string.IsNullOrEmpty(i.StoragePath))
|
||||
{
|
||||
i.StoragePath = string.Empty;
|
||||
}
|
||||
optionsBuilder.UseSqlite($"Data Source={Path.Combine(i.StoragePath, "OmbiSettings.db")}");
|
||||
}
|
||||
|
||||
public void Seed()
|
||||
{
|
||||
// Add the tokens
|
||||
var fanArt = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
|
||||
if (fanArt == null)
|
||||
{
|
||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||
{
|
||||
Type = ConfigurationTypes.FanartTv,
|
||||
Value = "4b6d983efa54d8f45c68432521335f15"
|
||||
});
|
||||
SaveChanges();
|
||||
}
|
||||
var movieDb = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
|
||||
if (movieDb == null)
|
||||
{
|
||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||
{
|
||||
Type = ConfigurationTypes.TheMovieDb,
|
||||
Value = "b8eabaf5608b88d0298aa189dd90bf00"
|
||||
});
|
||||
SaveChanges();
|
||||
}
|
||||
var notification = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Notification);
|
||||
if (notification == null)
|
||||
{
|
||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||
{
|
||||
Type = ConfigurationTypes.Notification,
|
||||
Value = "4f0260c4-9c3d-41ab-8d68-27cb5a593f0e"
|
||||
});
|
||||
SaveChanges();
|
||||
}
|
||||
|
||||
SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
50
src/Ombi.Store/Migrations/Settings/20181004132516_Inital.Designer.cs
generated
Normal file
50
src/Ombi.Store/Migrations/Settings/20181004132516_Inital.Designer.cs
generated
Normal file
|
@ -0,0 +1,50 @@
|
|||
// <auto-generated />
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Ombi.Store.Context;
|
||||
|
||||
namespace Ombi.Store.Migrations.Settings
|
||||
{
|
||||
[DbContext(typeof(SettingsContext))]
|
||||
[Migration("20181004132516_Inital")]
|
||||
partial class Inital
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.1.3-rtm-32065");
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.ApplicationConfiguration", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("Type");
|
||||
|
||||
b.Property<string>("Value");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("ApplicationConfiguration");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Content");
|
||||
|
||||
b.Property<string>("SettingsName");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("GlobalSettings");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
47
src/Ombi.Store/Migrations/Settings/20181004132516_Inital.cs
Normal file
47
src/Ombi.Store/Migrations/Settings/20181004132516_Inital.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Ombi.Store.Migrations.Settings
|
||||
{
|
||||
public partial class Inital : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ApplicationConfiguration",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Type = table.Column<int>(nullable: false),
|
||||
Value = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ApplicationConfiguration", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "GlobalSettings",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Content = table.Column<string>(nullable: true),
|
||||
SettingsName = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_GlobalSettings", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ApplicationConfiguration");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "GlobalSettings");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
// <auto-generated />
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Ombi.Store.Context;
|
||||
|
||||
namespace Ombi.Store.Migrations.Settings
|
||||
{
|
||||
[DbContext(typeof(SettingsContext))]
|
||||
partial class SettingsContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.1.3-rtm-32065");
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.ApplicationConfiguration", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("Type");
|
||||
|
||||
b.Property<string>("Value");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("ApplicationConfiguration");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Content");
|
||||
|
||||
b.Property<string>("SettingsName");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("GlobalSettings");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,16 +8,20 @@ namespace Ombi.Store.Repository
|
|||
{
|
||||
public class ApplicationConfigRepository : IApplicationConfigRepository
|
||||
{
|
||||
public ApplicationConfigRepository(IOmbiContext ctx)
|
||||
public ApplicationConfigRepository(ISettingsContext ctx)
|
||||
{
|
||||
Ctx = ctx;
|
||||
}
|
||||
|
||||
private IOmbiContext Ctx { get; }
|
||||
private ISettingsContext Ctx { get; }
|
||||
|
||||
public async Task<ApplicationConfiguration> Get(ConfigurationTypes type)
|
||||
public Task<ApplicationConfiguration> GetAsync(ConfigurationTypes type)
|
||||
{
|
||||
return await Ctx.ApplicationConfigurations.FirstOrDefaultAsync(x => x.Type == type);
|
||||
return Ctx.ApplicationConfigurations.FirstOrDefaultAsync(x => x.Type == type);
|
||||
}
|
||||
public ApplicationConfiguration Get(ConfigurationTypes type)
|
||||
{
|
||||
return Ctx.ApplicationConfigurations.FirstOrDefault(x => x.Type == type);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ namespace Ombi.Store.Repository
|
|||
{
|
||||
public interface IApplicationConfigRepository
|
||||
{
|
||||
Task<ApplicationConfiguration> Get(ConfigurationTypes type);
|
||||
Task<ApplicationConfiguration> GetAsync(ConfigurationTypes type);
|
||||
ApplicationConfiguration Get(ConfigurationTypes type);
|
||||
}
|
||||
}
|
|
@ -12,13 +12,13 @@ namespace Ombi.Store.Repository
|
|||
{
|
||||
public class SettingsJsonRepository : ISettingsRepository
|
||||
{
|
||||
public SettingsJsonRepository(IOmbiContext ctx, ICacheService mem)
|
||||
public SettingsJsonRepository(ISettingsContext ctx, ICacheService mem)
|
||||
{
|
||||
Db = ctx;
|
||||
_cache = mem;
|
||||
}
|
||||
|
||||
private IOmbiContext Db { get; }
|
||||
private ISettingsContext Db { get; }
|
||||
private readonly ICacheService _cache;
|
||||
|
||||
public GlobalSettings Insert(GlobalSettings entity)
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace Ombi.Controllers
|
|||
{
|
||||
return string.Empty;
|
||||
}
|
||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.GetAsync(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||
|
||||
var images = await FanartTvApi.GetTvImages(tvdbid, key.Value);
|
||||
if (images == null)
|
||||
|
@ -64,7 +64,7 @@ namespace Ombi.Controllers
|
|||
[HttpGet("poster/movie/{movieDbId}")]
|
||||
public async Task<string> GetMoviePoster(string movieDbId)
|
||||
{
|
||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.GetAsync(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||
|
||||
var images = await FanartTvApi.GetMovieImages(movieDbId, key.Value);
|
||||
|
||||
|
@ -98,7 +98,7 @@ namespace Ombi.Controllers
|
|||
{
|
||||
return string.Empty;
|
||||
}
|
||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.GetAsync(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||
|
||||
var images = await FanartTvApi.GetTvImages(tvdbid, key.Value);
|
||||
|
||||
|
@ -128,7 +128,7 @@ namespace Ombi.Controllers
|
|||
[HttpGet("background/movie/{movieDbId}")]
|
||||
public async Task<string> GetMovieBackground(string movieDbId)
|
||||
{
|
||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.GetAsync(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||
|
||||
var images = await FanartTvApi.GetMovieImages(movieDbId, key.Value);
|
||||
|
||||
|
@ -157,7 +157,7 @@ namespace Ombi.Controllers
|
|||
{
|
||||
return string.Empty;
|
||||
}
|
||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.GetAsync(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||
|
||||
var images = await FanartTvApi.GetTvImages(tvdbid, key.Value);
|
||||
|
||||
|
@ -189,7 +189,7 @@ namespace Ombi.Controllers
|
|||
var movieUrl = string.Empty;
|
||||
var tvUrl = string.Empty;
|
||||
|
||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.GetAsync(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||
|
||||
if (moviesArray.Length > 0)
|
||||
{
|
||||
|
|
|
@ -45,7 +45,9 @@ namespace Ombi
|
|||
var urlValue = string.Empty;
|
||||
var instance = StoragePathSingleton.Instance;
|
||||
instance.StoragePath = storagePath ?? string.Empty;
|
||||
using (var ctx = new OmbiContext())
|
||||
// Check if we need to migrate the settings
|
||||
CheckAndMigrate();
|
||||
using (var ctx = new SettingsContext())
|
||||
{
|
||||
var config = ctx.ApplicationConfigurations.ToList();
|
||||
var url = config.FirstOrDefault(x => x.Type == ConfigurationTypes.Url);
|
||||
|
@ -82,7 +84,7 @@ namespace Ombi
|
|||
ctx.SaveChanges();
|
||||
}
|
||||
}
|
||||
else if(baseUrl.HasValue() && !baseUrl.Equals(dbBaseUrl.Value))
|
||||
else if (baseUrl.HasValue() && !baseUrl.Equals(dbBaseUrl.Value))
|
||||
{
|
||||
dbBaseUrl.Value = baseUrl;
|
||||
ctx.SaveChanges();
|
||||
|
@ -96,6 +98,51 @@ namespace Ombi
|
|||
BuildWebHost(args).Run();
|
||||
}
|
||||
|
||||
private static void CheckAndMigrate()
|
||||
{
|
||||
var doneGlobal = false;
|
||||
var doneConfig = false;
|
||||
using (var ombi = new OmbiContext())
|
||||
using (var settings = new SettingsContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ombi.Settings.Any())
|
||||
{
|
||||
// OK migrate it!
|
||||
var allSettings = ombi.Settings.ToList();
|
||||
settings.Settings.AddRange(allSettings);
|
||||
doneGlobal = true;
|
||||
}
|
||||
|
||||
// Check for any application settings
|
||||
|
||||
if (ombi.ApplicationConfigurations.Any())
|
||||
{
|
||||
// OK migrate it!
|
||||
var allSettings = ombi.ApplicationConfigurations.ToList();
|
||||
settings.ApplicationConfigurations.AddRange(allSettings);
|
||||
doneConfig = true;
|
||||
}
|
||||
|
||||
settings.SaveChanges();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
|
||||
// Now delete the old stuff
|
||||
if(doneGlobal)
|
||||
ombi.Database.ExecuteSqlCommand("TRUNCATE TABLE GlobalSettings");
|
||||
if(doneConfig)
|
||||
ombi.Database.ExecuteSqlCommand("TRUNCATE TABLE ApplicationConfiguration");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void DeleteSchedulesDb()
|
||||
{
|
||||
try
|
||||
|
|
|
@ -177,7 +177,7 @@ namespace Ombi
|
|||
|
||||
// Check if it's in the startup args
|
||||
var appConfig = serviceProvider.GetService<IApplicationConfigRepository>();
|
||||
var baseUrl = appConfig.Get(ConfigurationTypes.BaseUrl).Result;
|
||||
var baseUrl = appConfig.Get(ConfigurationTypes.BaseUrl);
|
||||
if (baseUrl != null)
|
||||
{
|
||||
if (baseUrl.Value.HasValue())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue