mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Migrations
Still need to remove System.Data.Sqlite, prefer an option in OrmLite to pluralize table names.
This commit is contained in:
parent
b9fac94eca
commit
4bb4faf626
@ -123,7 +123,7 @@
|
||||
<Compile Include="Contract\ReportBase.cs" />
|
||||
<Compile Include="Contract\ParseErrorReport.cs" />
|
||||
<Compile Include="Model\AuthenticationType.cs" />
|
||||
<Compile Include="PathExtentions.cs" />
|
||||
<Compile Include="PathExtensions.cs" />
|
||||
<Compile Include="DiskProvider.cs" />
|
||||
<Compile Include="EnvironmentProvider.cs" />
|
||||
<Compile Include="Model\ProcessInfo.cs" />
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
public static class PathExtentions
|
||||
public static class PathExtensions
|
||||
{
|
||||
private const string WEB_FOLDER = "NzbDrone.Web\\";
|
||||
private const string APP_DATA = "App_Data\\";
|
||||
@ -135,5 +135,10 @@ public static string GetNzbDroneExe(this EnvironmentProvider environmentProvider
|
||||
{
|
||||
return Path.Combine(environmentProvider.ApplicationPath, NZBDRONE_EXE);
|
||||
}
|
||||
|
||||
public static string GetNzbDroneDatabase(this EnvironmentProvider environmentProvider)
|
||||
{
|
||||
return Path.Combine(environmentProvider.GetAppDataPath(), NZBDRONE_DB);
|
||||
}
|
||||
}
|
||||
}
|
@ -78,7 +78,7 @@ private void WaitForQueue()
|
||||
[Test]
|
||||
public void running_scheduled_jobs_should_updates_last_execution_time()
|
||||
{
|
||||
GivenPendingJob(new List<JobDefinition> { new JobDefinition { TypeName = _fakeJob.GetType().FullName } });
|
||||
GivenPendingJob(new List<JobDefinition> { new JobDefinition { Type = _fakeJob.GetType().FullName } });
|
||||
|
||||
Subject.EnqueueScheduled();
|
||||
WaitForQueue();
|
||||
@ -91,7 +91,7 @@ public void running_scheduled_jobs_should_updates_last_execution_time()
|
||||
[Test]
|
||||
public void failing_scheduled_job_should_mark_job_as_failed()
|
||||
{
|
||||
GivenPendingJob(new List<JobDefinition> { new JobDefinition { TypeName = _brokenJob.GetType().FullName } });
|
||||
GivenPendingJob(new List<JobDefinition> { new JobDefinition { Type = _brokenJob.GetType().FullName } });
|
||||
|
||||
Subject.EnqueueScheduled();
|
||||
WaitForQueue();
|
||||
@ -193,7 +193,7 @@ public void job_with_specific_target_should_not_update_status()
|
||||
[Test]
|
||||
public void Item_added_to_queue_while_scheduler_runs_should_be_executed()
|
||||
{
|
||||
GivenPendingJob(new List<JobDefinition> { new JobDefinition { TypeName = _slowJob.GetType().FullName } });
|
||||
GivenPendingJob(new List<JobDefinition> { new JobDefinition { Type = _slowJob.GetType().FullName } });
|
||||
|
||||
var jobThread = new Thread(Subject.EnqueueScheduled);
|
||||
jobThread.Start();
|
||||
@ -219,7 +219,7 @@ public void trygin_to_queue_unregistered_job_should_fail()
|
||||
[Test]
|
||||
public void scheduled_job_should_have_scheduler_as_source()
|
||||
{
|
||||
GivenPendingJob(new List<JobDefinition> { new JobDefinition { TypeName = _slowJob.GetType().FullName }, new JobDefinition { TypeName = _slowJob2.GetType().FullName } });
|
||||
GivenPendingJob(new List<JobDefinition> { new JobDefinition { Type = _slowJob.GetType().FullName }, new JobDefinition { Type = _slowJob2.GetType().FullName } });
|
||||
Subject.EnqueueScheduled();
|
||||
|
||||
Subject.Queue.Should().OnlyContain(c => c.Source == JobQueueItem.JobSourceType.Scheduler);
|
||||
|
@ -43,7 +43,7 @@ public void Init_should_add_defintaions()
|
||||
Storage.All().Should().HaveCount(1);
|
||||
StoredModel.Interval.Should().Be((Int32)_fakeJob.DefaultInterval.TotalMinutes);
|
||||
StoredModel.Name.Should().Be(_fakeJob.Name);
|
||||
StoredModel.TypeName.Should().Be(_fakeJob.GetType().ToString());
|
||||
StoredModel.Type.Should().Be(_fakeJob.GetType().ToString());
|
||||
StoredModel.LastExecution.Should().HaveYear(DateTime.Now.Year);
|
||||
StoredModel.LastExecution.Should().HaveMonth(DateTime.Now.Month);
|
||||
StoredModel.LastExecution.Should().HaveDay(DateTime.Today.Day);
|
||||
@ -66,7 +66,7 @@ public void inti_should_removed_jobs_that_no_longer_exist()
|
||||
Subject.Init();
|
||||
|
||||
AllStoredModels.Should().HaveCount(1);
|
||||
AllStoredModels.Should().NotContain(c => c.TypeName == deletedJob.TypeName);
|
||||
AllStoredModels.Should().NotContain(c => c.Type == deletedJob.Type);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -88,7 +88,7 @@ public void inti_should_removed_jobs_that_no_longer_exist_even_with_same_name()
|
||||
|
||||
|
||||
AllStoredModels.Should().HaveCount(1);
|
||||
AllStoredModels.Should().NotContain(c => c.TypeName == deletedJob.TypeName);
|
||||
AllStoredModels.Should().NotContain(c => c.Type == deletedJob.Type);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -98,7 +98,7 @@ public void init_should_update_existing_job()
|
||||
var oldJob = Builder<JobDefinition>.CreateNew()
|
||||
.With(c => c.Id = 0)
|
||||
.With(c => c.Name = "OldName")
|
||||
.With(c => c.TypeName = typeof(FakeJob).ToString())
|
||||
.With(c => c.Type = typeof(FakeJob).ToString())
|
||||
.With(c => c.Interval = 0)
|
||||
.With(c => c.Enable = true)
|
||||
.With(c => c.Success = true)
|
||||
@ -116,7 +116,7 @@ public void init_should_update_existing_job()
|
||||
|
||||
|
||||
AllStoredModels.Should().HaveCount(1);
|
||||
StoredModel.TypeName.Should().Be(newJob.GetType().FullName);
|
||||
StoredModel.Type.Should().Be(newJob.GetType().FullName);
|
||||
StoredModel.Name.Should().Be(newJob.Name);
|
||||
StoredModel.Interval.Should().Be((int)newJob.DefaultInterval.TotalMinutes);
|
||||
StoredModel.Enable.Should().Be(true);
|
||||
|
@ -7,7 +7,6 @@ public class Config : ModelBase
|
||||
{
|
||||
[Index(Unique = true)]
|
||||
public string Key { get; set; }
|
||||
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
@ -24,7 +24,6 @@ public static void RegisterCoreServices(this ContainerBuilder containerBuilder)
|
||||
|
||||
containerBuilder.InitDatabase();
|
||||
|
||||
|
||||
containerBuilder.RegisterModule<LogInjectionModule>();
|
||||
}
|
||||
|
||||
@ -53,22 +52,16 @@ private static void InitDatabase(this ContainerBuilder container)
|
||||
{
|
||||
logger.Info("Registering Database...");
|
||||
|
||||
var appDataPath = new EnvironmentProvider().GetAppDataPath();
|
||||
var environmentProvider = new EnvironmentProvider();
|
||||
var appDataPath = environmentProvider.GetAppDataPath();
|
||||
if (!Directory.Exists(appDataPath)) Directory.CreateDirectory(appDataPath);
|
||||
|
||||
container.Register(c =>
|
||||
{
|
||||
return c.Resolve<IDbFactory>().Create();
|
||||
}).As<IDbConnection>().SingleInstance();
|
||||
|
||||
|
||||
container.Register(c =>
|
||||
{
|
||||
return c.Resolve<IDbFactory>().Create();
|
||||
return c.Resolve<IDbFactory>().Create(environmentProvider.GetNzbDroneDatabase());
|
||||
}).As<IDbConnection>().SingleInstance();
|
||||
|
||||
container.RegisterGeneric(typeof(BasicRepository<>)).As(typeof(IBasicRepository<>));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -28,6 +28,8 @@ public IDbConnection Create(string dbPath = null)
|
||||
connectionString = GetConnectionString(dbPath);
|
||||
}
|
||||
|
||||
MigrationHelper.MigrateToLatest(connectionString, MigrationType.Main);
|
||||
|
||||
OrmLiteConfig.DialectProvider = new SqliteOrmLiteDialectProvider();
|
||||
var dbFactory = new OrmLiteConnectionFactory(connectionString);
|
||||
var connection = dbFactory.Open();
|
||||
|
38
NzbDrone.Core/Datastore/MigrationHelper.cs
Normal file
38
NzbDrone.Core/Datastore/MigrationHelper.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using FluentMigrator;
|
||||
using FluentMigrator.Runner;
|
||||
using FluentMigrator.Runner.Initialization;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public static class MigrationHelper
|
||||
{
|
||||
public static void MigrateToLatest(string connectionString, MigrationType migrationType)
|
||||
{
|
||||
var announcer = new NlogAnnouncer();
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
var migrationContext = new RunnerContext(announcer)
|
||||
{
|
||||
Namespace = "NzbDrone.Core.Datastore.Migrations",
|
||||
ApplicationContext = migrationType
|
||||
};
|
||||
|
||||
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
|
||||
var factory = new FluentMigrator.Runner.Processors.Sqlite.SqliteProcessorFactory();
|
||||
var processor = factory.Create(connectionString, announcer, options);
|
||||
var runner = new MigrationRunner(assembly, migrationContext, processor);
|
||||
runner.MigrateUp(true);
|
||||
}
|
||||
}
|
||||
|
||||
public class MigrationOptions : IMigrationProcessorOptions
|
||||
{
|
||||
public bool PreviewOnly { get; set; }
|
||||
public int Timeout { get; set; }
|
||||
}
|
||||
}
|
13
NzbDrone.Core/Datastore/MigrationType.cs
Normal file
13
NzbDrone.Core/Datastore/MigrationType.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public enum MigrationType
|
||||
{
|
||||
Main,
|
||||
Log
|
||||
}
|
||||
}
|
168
NzbDrone.Core/Datastore/Migrations/Migration20130324.cs
Normal file
168
NzbDrone.Core/Datastore/Migrations/Migration20130324.cs
Normal file
@ -0,0 +1,168 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using FluentMigrator;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
[Tags("")]
|
||||
[Migration(20130324)]
|
||||
public class Migration20130324 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Create.Table("Config")
|
||||
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
|
||||
.WithColumn("Key").AsString().PrimaryKey()
|
||||
.WithColumn("Value").AsString().NotNullable();
|
||||
|
||||
Create.Table("EpisodeFiles")
|
||||
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
|
||||
.WithColumn("SeriesId").AsInt32().NotNullable()
|
||||
.WithColumn("Path").AsString().NotNullable()
|
||||
.WithColumn("Quality").AsInt32().NotNullable()
|
||||
.WithColumn("Proper").AsBoolean().NotNullable()
|
||||
.WithColumn("Size").AsInt64().NotNullable()
|
||||
.WithColumn("DateAdded").AsDateTime().NotNullable()
|
||||
.WithColumn("SeasonNumber").AsInt32().NotNullable()
|
||||
.WithColumn("SceneName").AsString().Nullable()
|
||||
.WithColumn("ReleaseGroup").AsString().Nullable();
|
||||
|
||||
Create.Table("Episodes")
|
||||
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
|
||||
.WithColumn("TvdbId").AsInt32().Nullable()
|
||||
.WithColumn("SeriesId").AsInt32().NotNullable()
|
||||
.WithColumn("SeasonNumber").AsInt32().NotNullable()
|
||||
.WithColumn("EpisodeNumber").AsInt32().NotNullable()
|
||||
.WithColumn("Title").AsString().Nullable()
|
||||
.WithColumn("Overview").AsString().Nullable()
|
||||
.WithColumn("Ignored").AsBoolean().Nullable()
|
||||
.WithColumn("EpisodeFileId").AsInt32().Nullable()
|
||||
.WithColumn("AirDate").AsDateTime().Nullable()
|
||||
.WithColumn("GrabDate").AsDateTime().Nullable()
|
||||
.WithColumn("PostDownloadStatus").AsInt32().Nullable()
|
||||
.WithColumn("AbsoluteEpisodeNumber").AsInt32().Nullable()
|
||||
.WithColumn("SceneAbsoluteEpisodeNumber").AsInt32().Nullable()
|
||||
.WithColumn("SceneSeasonNumber").AsInt32().Nullable()
|
||||
.WithColumn("SceneEpisodeNumber").AsInt32().Nullable();
|
||||
|
||||
Create.Table("ExternalNotificationDefinitions")
|
||||
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
|
||||
.WithColumn("Enable").AsBoolean().NotNullable()
|
||||
.WithColumn("Type").AsString().NotNullable()
|
||||
.WithColumn("Name").AsString().NotNullable();
|
||||
|
||||
Create.Table("History")
|
||||
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
|
||||
.WithColumn("EpisodeId").AsInt32().NotNullable()
|
||||
.WithColumn("SeriesId").AsInt32().NotNullable()
|
||||
.WithColumn("NzbTitle").AsString().NotNullable()
|
||||
.WithColumn("Date").AsDateTime().NotNullable()
|
||||
.WithColumn("Quality").AsInt32().NotNullable()
|
||||
.WithColumn("Proper").AsBoolean().NotNullable()
|
||||
.WithColumn("Indexer").AsString().NotNullable()
|
||||
.WithColumn("NzbInfoUrl").AsString().Nullable()
|
||||
.WithColumn("ReleaseGroup").AsString().Nullable();
|
||||
|
||||
Create.Table("IndexerDefinitions")
|
||||
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
|
||||
.WithColumn("Enable").AsBoolean().NotNullable()
|
||||
.WithColumn("Type").AsString().NotNullable()
|
||||
.WithColumn("Name").AsString().NotNullable();
|
||||
|
||||
Create.Table("JobDefinitions")
|
||||
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
|
||||
.WithColumn("Enable").AsBoolean().NotNullable()
|
||||
.WithColumn("Type").AsString().NotNullable()
|
||||
.WithColumn("Name").AsString().NotNullable()
|
||||
.WithColumn("Interval").AsInt32().NotNullable()
|
||||
.WithColumn("LastExecution").AsDateTime().NotNullable()
|
||||
.WithColumn("Success").AsBoolean().NotNullable();
|
||||
|
||||
Create.Table("MetadataDefinitions")
|
||||
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
|
||||
.WithColumn("Enable").AsBoolean().NotNullable()
|
||||
.WithColumn("Type").AsString().NotNullable()
|
||||
.WithColumn("Name").AsString().NotNullable();
|
||||
|
||||
Create.Table("NewznabDefinitions")
|
||||
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
|
||||
.WithColumn("Enable").AsBoolean().NotNullable()
|
||||
.WithColumn("Name").AsString().NotNullable()
|
||||
.WithColumn("Url").AsString().NotNullable()
|
||||
.WithColumn("ApiKey").AsString().Nullable()
|
||||
.WithColumn("BuiltIn").AsBoolean().NotNullable();
|
||||
|
||||
Create.Table("QualityProfiles")
|
||||
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
|
||||
.WithColumn("Name").AsString().NotNullable()
|
||||
.WithColumn("Cutoff").AsInt32().NotNullable()
|
||||
.WithColumn("Allowed").AsString().NotNullable();
|
||||
|
||||
Create.Table("QualitySizes")
|
||||
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
|
||||
.WithColumn("QualityId").AsInt32().NotNullable().Unique()
|
||||
.WithColumn("Name").AsString().NotNullable()
|
||||
.WithColumn("MinSize").AsInt32().NotNullable()
|
||||
.WithColumn("MaxSize").AsInt32().NotNullable();
|
||||
|
||||
Create.Table("RootFolders")
|
||||
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
|
||||
.WithColumn("Path").AsString().NotNullable();
|
||||
|
||||
Create.Table("SceneMappings")
|
||||
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
|
||||
.WithColumn("CleanTitle").AsString().NotNullable()
|
||||
.WithColumn("SceneName").AsString().NotNullable()
|
||||
.WithColumn("SeriesId").AsInt32().NotNullable()
|
||||
.WithColumn("SeasonNumber").AsInt32().NotNullable();
|
||||
|
||||
Create.Table("Seasons")
|
||||
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
|
||||
.WithColumn("SeriesId").AsInt32().NotNullable()
|
||||
.WithColumn("SeasonNumber").AsInt32().NotNullable()
|
||||
.WithColumn("Ignored").AsBoolean().NotNullable();
|
||||
|
||||
Create.Table("Series")
|
||||
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
|
||||
.WithColumn("TvdbId").AsInt32().NotNullable()
|
||||
.WithColumn("Title").AsString().NotNullable()
|
||||
.WithColumn("CleanTitle").AsString().NotNullable()
|
||||
.WithColumn("Status").AsInt32().NotNullable()
|
||||
.WithColumn("Overview").AsString().NotNullable()
|
||||
.WithColumn("AirTime").AsString().Nullable()
|
||||
.WithColumn("Language").AsString().NotNullable()
|
||||
.WithColumn("Path").AsString().NotNullable()
|
||||
.WithColumn("Monitored").AsBoolean().NotNullable()
|
||||
.WithColumn("QualityProfileId").AsString().NotNullable()
|
||||
.WithColumn("SeasonFolder").AsBoolean().NotNullable()
|
||||
.WithColumn("LastInfoSync").AsDateTime().Nullable()
|
||||
.WithColumn("LastDiskSync").AsDateTime().Nullable()
|
||||
.WithColumn("Runtime").AsInt32().NotNullable()
|
||||
.WithColumn("BannerUrl").AsString().NotNullable()
|
||||
.WithColumn("SeriesType").AsInt32().NotNullable()
|
||||
.WithColumn("BacklogSetting").AsInt32().NotNullable()
|
||||
.WithColumn("Network").AsString().NotNullable()
|
||||
.WithColumn("CustomStartDate").AsDateTime().Nullable()
|
||||
.WithColumn("UseSceneNumbering").AsBoolean().NotNullable()
|
||||
.WithColumn("TvRageId").AsInt32().Nullable()
|
||||
.WithColumn("TvRageTitle").AsString().NotNullable()
|
||||
.WithColumn("UtcOffSet").AsInt32().NotNullable()
|
||||
.WithColumn("FirstAired").AsDateTime().Nullable();
|
||||
}
|
||||
|
||||
protected override void LogDbUpgrade()
|
||||
{
|
||||
Create.Table("Logs")
|
||||
.WithColumn("LogId").AsInt64().PrimaryKey().Identity()
|
||||
.WithColumn("Message").AsString().NotNullable()
|
||||
.WithColumn("Time").AsDateTime().NotNullable()
|
||||
.WithColumn("Logger").AsString().NotNullable()
|
||||
.WithColumn("Method").AsString().NotNullable()
|
||||
.WithColumn("Exception").AsString().Nullable()
|
||||
.WithColumn("ExceptionType").AsString().Nullable()
|
||||
.WithColumn("Level").AsString().NotNullable();
|
||||
}
|
||||
}
|
||||
}
|
43
NzbDrone.Core/Datastore/Migrations/NzbDroneMigration.cs
Normal file
43
NzbDrone.Core/Datastore/Migrations/NzbDroneMigration.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using FluentMigrator;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
public abstract class NzbDroneMigration : Migration
|
||||
{
|
||||
protected virtual void MainDbUpgrade()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void LogDbUpgrade()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Up()
|
||||
{
|
||||
if ((MigrationType)this.ApplicationContext == MigrationType.Main)
|
||||
{
|
||||
MainDbUpgrade();
|
||||
}
|
||||
else if ((MigrationType)this.ApplicationContext == MigrationType.Log)
|
||||
{
|
||||
LogDbUpgrade();
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDbUpgrade();
|
||||
MainDbUpgrade();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
19
NzbDrone.Core/Datastore/NlogAnnouncer.cs
Normal file
19
NzbDrone.Core/Datastore/NlogAnnouncer.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using FluentMigrator.Runner.Announcers;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public class NlogAnnouncer : Announcer
|
||||
{
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public override void Write(string message, bool escaped)
|
||||
{
|
||||
logger.Info(message);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using ServiceStack.DataAnnotations;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
[Alias("IndexerDefinitions")]
|
||||
public class Indexer : ModelBase
|
||||
{
|
||||
public Boolean Enable { get; set; }
|
||||
|
@ -1,12 +1,14 @@
|
||||
using System;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using ServiceStack.DataAnnotations;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
[Alias("NewznabDefinitions")]
|
||||
public class NewznabDefinition : ModelBase
|
||||
{
|
||||
public Boolean Enabled { get; set; }
|
||||
public Boolean Enable { get; set; }
|
||||
public String Name { get; set; }
|
||||
public String Url { get; set; }
|
||||
public String ApiKey { get; set; }
|
||||
|
@ -20,7 +20,7 @@ public NewznabRepository(IDbConnection database) : base(database)
|
||||
|
||||
public IEnumerable<NewznabDefinition> Enabled()
|
||||
{
|
||||
return Where(n => n.Enabled);
|
||||
return Where(n => n.Enable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,9 +79,9 @@ public void Init()
|
||||
{
|
||||
var newznabIndexers = new List<NewznabDefinition>
|
||||
{
|
||||
new NewznabDefinition { Enabled = false, Name = "Nzbs.org", Url = "http://nzbs.org", BuiltIn = true },
|
||||
new NewznabDefinition { Enabled = false, Name = "Nzb.su", Url = "https://nzb.su", BuiltIn = true },
|
||||
new NewznabDefinition { Enabled = false, Name = "Dognzb.cr", Url = "https://dognzb.cr", BuiltIn = true }
|
||||
new NewznabDefinition { Enable = false, Name = "Nzbs.org", Url = "http://nzbs.org", BuiltIn = true },
|
||||
new NewznabDefinition { Enable = false, Name = "Nzb.su", Url = "https://nzb.su", BuiltIn = true },
|
||||
new NewznabDefinition { Enable = false, Name = "Dognzb.cr", Url = "https://dognzb.cr", BuiltIn = true }
|
||||
};
|
||||
|
||||
_logger.Debug("Initializing Newznab indexers. Count {0}", newznabIndexers);
|
||||
@ -108,7 +108,7 @@ public void Init()
|
||||
{
|
||||
var definition = new NewznabDefinition
|
||||
{
|
||||
Enabled = false,
|
||||
Enable = false,
|
||||
Name = indexerLocal.Name,
|
||||
Url = indexerLocal.Url,
|
||||
ApiKey = indexerLocal.ApiKey,
|
||||
|
@ -42,10 +42,8 @@ public JobController(NotificationProvider notificationProvider, IEnumerable<IJob
|
||||
Task.Factory.StartNew(ProcessQueue, _cancellationTokenSource.Token);
|
||||
}
|
||||
|
||||
|
||||
public bool IsProcessing { get; private set; }
|
||||
|
||||
|
||||
public IEnumerable<JobQueueItem> Queue
|
||||
{
|
||||
get
|
||||
@ -63,7 +61,7 @@ public void EnqueueScheduled()
|
||||
}
|
||||
|
||||
var pendingJobs = _jobRepository.GetPendingJobs()
|
||||
.Select(c => _jobs.Single(t => t.GetType().ToString() == c.TypeName)
|
||||
.Select(c => _jobs.Single(t => t.GetType().ToString() == c.Type)
|
||||
.GetType()).ToList();
|
||||
|
||||
|
||||
@ -99,7 +97,6 @@ public void Enqueue(Type jobType, dynamic options = null, JobQueueItem.JobSource
|
||||
|
||||
}
|
||||
|
||||
|
||||
public bool Enqueue(string jobTypeString)
|
||||
{
|
||||
var type = Type.GetType(jobTypeString);
|
||||
|
@ -1,21 +1,18 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using ServiceStack.DataAnnotations;
|
||||
|
||||
namespace NzbDrone.Core.Jobs
|
||||
{
|
||||
[Alias("JobDefinitions")]
|
||||
public class JobDefinition : ModelBase
|
||||
{
|
||||
public Boolean Enable { get; set; }
|
||||
|
||||
public String TypeName { get; set; }
|
||||
|
||||
public String Type { get; set; }
|
||||
public String Name { get; set; }
|
||||
|
||||
public Int32 Interval { get; set; }
|
||||
|
||||
public DateTime LastExecution { get; set; }
|
||||
|
||||
public Boolean Success { get; set; }
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ public JobRepository(IDbConnection database, IEnumerable<IJob> jobs, Logger logg
|
||||
|
||||
public JobDefinition GetDefinition(Type type)
|
||||
{
|
||||
return Single(c => c.TypeName == type.FullName);
|
||||
return Single(c => c.Type == type.FullName);
|
||||
}
|
||||
|
||||
|
||||
@ -39,12 +39,12 @@ public IList<JobDefinition> GetPendingJobs()
|
||||
|
||||
public void Init()
|
||||
{
|
||||
var currentJobs = All();
|
||||
var currentJobs = All().ToList();
|
||||
_logger.Debug("Initializing jobs. Available: {0} Existing:{1}", _jobs.Count(), currentJobs.Count());
|
||||
|
||||
foreach (var currentJob in currentJobs)
|
||||
{
|
||||
if (_jobs.All(c => c.GetType().ToString() != currentJob.TypeName))
|
||||
if (_jobs.All(c => c.GetType().ToString() != currentJob.Type))
|
||||
{
|
||||
_logger.Debug("Removing job from database '{0}'", currentJob.Name);
|
||||
Delete(currentJob.Id);
|
||||
@ -53,13 +53,13 @@ public void Init()
|
||||
|
||||
foreach (var job in _jobs)
|
||||
{
|
||||
var jobDefinition = currentJobs.SingleOrDefault(c => c.TypeName == job.GetType().ToString());
|
||||
var jobDefinition = currentJobs.SingleOrDefault(c => c.Type == job.GetType().ToString());
|
||||
|
||||
if (jobDefinition == null)
|
||||
{
|
||||
jobDefinition = new JobDefinition
|
||||
{
|
||||
TypeName = job.GetType().ToString(),
|
||||
Type = job.GetType().ToString(),
|
||||
LastExecution = DateTime.Now
|
||||
};
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public virtual Series GetSeries(int tvDbSeriesId)
|
||||
series.Title = tvDbSeries.SeriesName;
|
||||
series.AirTime = CleanAirsTime(tvDbSeries.Airs_Time);
|
||||
series.Overview = tvDbSeries.Overview;
|
||||
series.Status = tvDbSeries.Status;
|
||||
series.Status = tvDbSeries.Status == "Continuing" ? SeriesStatusType.Continuing : SeriesStatusType.Ended ;
|
||||
series.Language = tvDbSeries.Language ?? string.Empty;
|
||||
series.CleanTitle = Parser.NormalizeTitle(tvDbSeries.SeriesName);
|
||||
series.LastInfoSync = DateTime.Now;
|
||||
|
@ -127,6 +127,12 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FluentMigrator">
|
||||
<HintPath>..\packages\FluentMigrator.1.0.6.0\lib\40\FluentMigrator.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FluentMigrator.Runner">
|
||||
<HintPath>..\packages\FluentMigrator.1.0.6.0\tools\FluentMigrator.Runner.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Growl.Connector">
|
||||
<HintPath>..\packages\Growl.0.6\lib\Growl.Connector.dll</HintPath>
|
||||
</Reference>
|
||||
@ -181,6 +187,14 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.SQLite, Version=1.0.84.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\System.Data.SQLite.x64.1.0.84.0\lib\net40\System.Data.SQLite.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.SQLite.Linq, Version=1.0.84.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\System.Data.SQLite.x64.1.0.84.0\lib\net40\System.Data.SQLite.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Web" />
|
||||
@ -201,9 +215,14 @@
|
||||
<Compile Include="Constants.cs" />
|
||||
<Compile Include="ContainerExtensions.cs" />
|
||||
<Compile Include="Datastore\DbFactory.cs" />
|
||||
<Compile Include="Datastore\MigrationHelper.cs" />
|
||||
<Compile Include="Datastore\Migration.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20130324.cs" />
|
||||
<Compile Include="Datastore\Migrations\NzbDroneMigration.cs" />
|
||||
<Compile Include="Datastore\MigrationType.cs" />
|
||||
<Compile Include="Datastore\ModelBase.cs" />
|
||||
<Compile Include="Datastore\BasicRepository.cs" />
|
||||
<Compile Include="Datastore\NlogAnnouncer.cs" />
|
||||
<Compile Include="DecisionEngine\DownloadDecision.cs" />
|
||||
<Compile Include="DecisionEngine\IFetchableSpecification.cs" />
|
||||
<Compile Include="DecisionEngine\Specifications\AcceptableSizeSpecification.cs" />
|
||||
@ -530,6 +549,7 @@
|
||||
<Compile Include="Tvdb\TvdbServerTime.cs" />
|
||||
<Compile Include="Tvdb\TvdbUpdate.cs" />
|
||||
<Compile Include="Tvdb\TvdbUpdateItems.cs" />
|
||||
<Compile Include="Tv\SeriesStatusType.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
|
||||
|
@ -1,9 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using ServiceStack.DataAnnotations;
|
||||
|
||||
namespace NzbDrone.Core.Qualities
|
||||
{
|
||||
[Alias("QualityProfiles")]
|
||||
public class QualityProfile : ModelBase
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
@ -1,9 +1,11 @@
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using ServiceStack.DataAnnotations;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Qualities
|
||||
{
|
||||
[Alias("QualitySizes")]
|
||||
public class QualitySize : ModelBase
|
||||
{
|
||||
public int QualityId { get; set; }
|
||||
|
@ -1,8 +1,10 @@
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using ServiceStack.DataAnnotations;
|
||||
|
||||
namespace NzbDrone.Core.ReferenceData
|
||||
{
|
||||
[Alias("SceneMappings")]
|
||||
public class SceneMapping : ModelBase
|
||||
{
|
||||
public string CleanTitle { get; set; }
|
||||
|
@ -4,7 +4,7 @@
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
using ServiceStack.DataAnnotations;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Tv
|
||||
@ -21,11 +21,8 @@ public class Series : ModelBase
|
||||
public int TvDbId { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string CleanTitle { get; set; }
|
||||
public string Status { get; set; }
|
||||
|
||||
|
||||
public SeriesStatusType Status { get; set; }
|
||||
public string Overview { get; set; }
|
||||
|
||||
public String AirTime { get; set; }
|
||||
public string Language { get; set; }
|
||||
public string Path { get; set; }
|
||||
|
13
NzbDrone.Core/Tv/SeriesStatusType.cs
Normal file
13
NzbDrone.Core/Tv/SeriesStatusType.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Tv
|
||||
{
|
||||
public enum SeriesStatusType
|
||||
{
|
||||
Continuing = 0,
|
||||
Ended = 1
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
<packages>
|
||||
<package id="Autofac" version="3.0.1" targetFramework="net40" />
|
||||
<package id="DotNetZip" version="1.9.1.8" />
|
||||
<package id="FluentMigrator" version="1.0.6.0" targetFramework="net40" />
|
||||
<package id="Growl" version="0.6" />
|
||||
<package id="MediaInfoNet" version="0.3" targetFramework="net40" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
|
||||
@ -14,5 +15,6 @@
|
||||
<package id="ServiceStack.Text" version="3.9.42" targetFramework="net40" />
|
||||
<package id="SignalR.Hosting.Common" version="0.5.3" targetFramework="net40" />
|
||||
<package id="SignalR.Server" version="0.5.3" targetFramework="net40" />
|
||||
<package id="System.Data.SQLite.x86" version="1.0.84.0" targetFramework="net40" />
|
||||
<package id="twitterizer" version="2.4.0.26532" />
|
||||
</packages>
|
@ -89,6 +89,14 @@
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.SQLite, Version=1.0.84.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=AMD64">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\System.Data.SQLite.x86.1.0.84.0\lib\net40\System.Data.SQLite.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.SQLite.Linq, Version=1.0.84.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\System.Data.SQLite.x86.1.0.84.0\lib\net40\System.Data.SQLite.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -9,4 +9,5 @@
|
||||
<package id="NLog" version="2.0.0.2000" />
|
||||
<package id="NLog.Config" version="2.0.0.2000" targetFramework="net40" />
|
||||
<package id="NLog.Schema" version="2.0.0.2000" targetFramework="net40" />
|
||||
<package id="System.Data.SQLite.x86" version="1.0.84.0" targetFramework="net40" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user