diff --git a/.gitignore b/.gitignore index 62edc661d..f67b7748f 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,6 @@ _ReSharper*/ NzbDrone.Web/NzbDrone.Web.Publish.xml *.sdf [Bb]anners -*.orig \ No newline at end of file +*.orig +_rawPackage/ +NzbDrone.zip \ No newline at end of file diff --git a/NzbDrone.6.0.ReSharper b/NzbDrone.6.0.ReSharper index c4e417d31..04c374209 100644 --- a/NzbDrone.6.0.ReSharper +++ b/NzbDrone.6.0.ReSharper @@ -97,7 +97,7 @@ $object$_On$event$ $event$Handler - + diff --git a/NzbDrone.Common/EnviromentProvider.cs b/NzbDrone.Common/EnviromentProvider.cs index 60dd21a52..6b73c980d 100644 --- a/NzbDrone.Common/EnviromentProvider.cs +++ b/NzbDrone.Common/EnviromentProvider.cs @@ -7,23 +7,20 @@ namespace NzbDrone.Common { public class EnviromentProvider { - public virtual String LogPath - { - get { return Environment.CurrentDirectory; } - } - public virtual bool IsUserInteractive - { - get { return Environment.UserInteractive; } - } +#if DEBUG + private static readonly bool isInDebug = true; +#else + private static readonly bool isInDebug = false; +#endif + + private static readonly string processName = Process.GetCurrentProcess().ProcessName.ToLower(); public static bool IsProduction { get { - if (Debugger.IsAttached) return false; - - var processName = Process.GetCurrentProcess().ProcessName.ToLower(); + if (isInDebug || Debugger.IsAttached) return false; Console.WriteLine(processName); if (processName.Contains("nunit")) return false; @@ -34,6 +31,16 @@ public static bool IsProduction } } + public virtual String LogPath + { + get { return Environment.CurrentDirectory; } + } + + public virtual bool IsUserInteractive + { + get { return Environment.UserInteractive; } + } + public virtual string ApplicationPath { get @@ -60,6 +67,26 @@ public virtual string ApplicationPath } } + public virtual string WebRoot + { + get + { + return Path.Combine(ApplicationPath, "NzbDrone.Web"); + } + } + + public virtual string AppDataPath + { + get + { + var path = Path.Combine(WebRoot, "App_data"); + if (!Directory.Exists(path)) + Directory.CreateDirectory(path); + + return path; + } + } + public virtual string StartUpPath { get @@ -68,6 +95,30 @@ public virtual string StartUpPath } } + public virtual Version Version + { + get { return Assembly.GetExecutingAssembly().GetName().Version; } + } + + public virtual DateTime BuildDateTime + { + get + { + var fileLocation = Assembly.GetCallingAssembly().Location; + return new FileInfo(fileLocation).CreationTime; + } + + } + + + public virtual String TempPath + { + get + { + return Path.GetTempPath(); + } + } + private static bool ContainsIIS(DirectoryInfo dir) { return dir.GetDirectories("iisexpress").Length != 0; diff --git a/NzbDrone.Core.Test/JobTests/BannerDownloadJobTest.cs b/NzbDrone.Core.Test/JobTests/BannerDownloadJobTest.cs index 4724f626c..58a678bdd 100644 --- a/NzbDrone.Core.Test/JobTests/BannerDownloadJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/BannerDownloadJobTest.cs @@ -4,12 +4,14 @@ using FizzWare.NBuilder; using Moq; using NUnit.Framework; +using NzbDrone.Common; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Jobs; using NzbDrone.Core.Repository; using NzbDrone.Core.Test.Framework; +using DiskProvider = NzbDrone.Core.Providers.Core.DiskProvider; namespace NzbDrone.Core.Test.JobTests { @@ -90,7 +92,7 @@ public void BannerDownload_some_failed_download() var fakeSeries = Builder.CreateListOfSize(10) .Build(); - var path = Path.Combine(new EnviromentProvider().AppPath, "Content", "Images", "Banners"); + var path = Path.Combine(new EnviromentProvider().WebRoot, "Content", "Images", "Banners"); var mocker = new AutoMoqer(MockBehavior.Strict); mocker.Resolve(); diff --git a/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs index ebaa0752a..a7e570261 100644 --- a/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs @@ -5,6 +5,7 @@ using System.Linq; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Common; using NzbDrone.Core.Providers; using NzbDrone.Core.Test.Framework; using TvdbLib.Data; diff --git a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs index 0048c4bf1..5e30f3206 100644 --- a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs @@ -3,6 +3,7 @@ using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Common; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Test.Framework; diff --git a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/PreformUpdateFixture.cs b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/PreformUpdateFixture.cs index 3ef354107..68e28f688 100644 --- a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/PreformUpdateFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/PreformUpdateFixture.cs @@ -4,10 +4,12 @@ using FluentAssertions; using Moq; using NUnit.Framework; +using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Test.Framework; +using DiskProvider = NzbDrone.Core.Providers.Core.DiskProvider; namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests { diff --git a/NzbDrone.Core/Datastore/Connection.cs b/NzbDrone.Core/Datastore/Connection.cs index 631f522cd..7c05d377f 100644 --- a/NzbDrone.Core/Datastore/Connection.cs +++ b/NzbDrone.Core/Datastore/Connection.cs @@ -4,6 +4,7 @@ using System.Data.SqlServerCe; using System.IO; using MvcMiniProfiler.Data; +using NzbDrone.Common; using NzbDrone.Core.Providers; using PetaPoco; @@ -11,11 +12,10 @@ namespace NzbDrone.Core.Datastore { public static class Connection { - private static readonly DirectoryInfo AppDataPath = new DirectoryInfo(Path.Combine(new EnviromentProvider().AppPath, "App_Data")); + private static EnviromentProvider _enviromentProvider = new EnviromentProvider(); static Connection() { - if (!AppDataPath.Exists) AppDataPath.Create(); Database.Mapper = new CustomeMapper(); } @@ -30,7 +30,7 @@ public static String MainConnectionString { get { - return GetConnectionString(Path.Combine(AppDataPath.FullName, "nzbdrone.sdf")); + return GetConnectionString(Path.Combine(_enviromentProvider.AppDataPath, "nzbdrone.sdf")); } } @@ -38,7 +38,7 @@ public static String LogConnectionString { get { - return GetConnectionString(Path.Combine(AppDataPath.FullName, "log.sdf")); + return GetConnectionString(Path.Combine(_enviromentProvider.AppDataPath, "log.sdf")); } } diff --git a/NzbDrone.Core/Instrumentation/LogConfiguration.cs b/NzbDrone.Core/Instrumentation/LogConfiguration.cs index d21d8690a..d94c6d520 100644 --- a/NzbDrone.Core/Instrumentation/LogConfiguration.cs +++ b/NzbDrone.Core/Instrumentation/LogConfiguration.cs @@ -2,6 +2,7 @@ using Ninject; using NLog; using NLog.Config; +using NzbDrone.Common; using NzbDrone.Core.Providers; namespace NzbDrone.Core.Instrumentation @@ -16,7 +17,7 @@ public static void Setup() LogManager.ThrowExceptions = false; } - LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(new EnviromentProvider().AppPath, "log.config"), false); + LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(new EnviromentProvider().WebRoot, "log.config"), false); Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Web.MvcApplication"); Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Core.CentralDispatch"); diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index d91b26a96..fe08841d8 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -219,7 +219,6 @@ - diff --git a/NzbDrone.Core/Providers/Core/ConfigFileProvider.cs b/NzbDrone.Core/Providers/Core/ConfigFileProvider.cs index 7ee204018..5047fec37 100644 --- a/NzbDrone.Core/Providers/Core/ConfigFileProvider.cs +++ b/NzbDrone.Core/Providers/Core/ConfigFileProvider.cs @@ -1,17 +1,15 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; -using System.Text; using System.Xml.Linq; +using NzbDrone.Common; using NzbDrone.Core.Model; namespace NzbDrone.Core.Providers.Core { public class ConfigFileProvider { - private string _configFile = Path.Combine(new EnviromentProvider().AppPath, "App_Data", "Config.xml"); + private string _configFile = Path.Combine(new EnviromentProvider().AppDataPath, "Config.xml"); public string ConfigFile { @@ -112,22 +110,14 @@ public virtual void SetValue(string key, object value, string parent = null) public virtual void CreateDefaultConfigFile() { - //Create the config file here - Directory.CreateDirectory(Path.Combine(new EnviromentProvider().AppPath, "App_Data")); - if (!File.Exists(ConfigFile)) { - WriteDefaultConfig(); + var xDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes")); + + xDoc.Add(new XElement("Config")); + + xDoc.Save(ConfigFile); } } - - public virtual void WriteDefaultConfig() - { - var xDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes")); - - xDoc.Add(new XElement("Config")); - - xDoc.Save(ConfigFile); - } } } diff --git a/NzbDrone.Core/Providers/EnviromentProvider.cs b/NzbDrone.Core/Providers/EnviromentProvider.cs deleted file mode 100644 index 85440060a..000000000 --- a/NzbDrone.Core/Providers/EnviromentProvider.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Text.RegularExpressions; -using System.Web.Hosting; -using NLog; -using Ninject; -using NzbDrone.Core.Model; -using NzbDrone.Core.Providers.Core; - -namespace NzbDrone.Core.Providers -{ - public class EnviromentProvider - { - - public virtual Version Version - { - get { return Assembly.GetExecutingAssembly().GetName().Version; } - } - - public virtual DateTime BuildDateTime - { - get - { - var fileLocation = Assembly.GetCallingAssembly().Location; - return new FileInfo(fileLocation).CreationTime; - } - - } - - public virtual String AppPath - { - get - { - if (!String.IsNullOrWhiteSpace(HostingEnvironment.ApplicationPhysicalPath)) - { - return HostingEnvironment.ApplicationPhysicalPath; - } - return Directory.GetCurrentDirectory(); - } - } - - public virtual String TempPath - { - get - { - return Path.GetTempPath(); - } - } - - } -} diff --git a/NzbDrone.Core/Providers/Jobs/BannerDownloadJob.cs b/NzbDrone.Core/Providers/Jobs/BannerDownloadJob.cs index 83f5090ad..15e0ad431 100644 --- a/NzbDrone.Core/Providers/Jobs/BannerDownloadJob.cs +++ b/NzbDrone.Core/Providers/Jobs/BannerDownloadJob.cs @@ -4,9 +4,11 @@ using System.Linq; using Ninject; using NLog; +using NzbDrone.Common; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Repository; +using DiskProvider = NzbDrone.Core.Providers.Core.DiskProvider; namespace NzbDrone.Core.Providers.Jobs { @@ -49,7 +51,7 @@ public virtual void Start(ProgressNotification notification, int targetId, int s { Logger.Debug("Starting banner download job"); - _bannerPath = Path.Combine(_enviromentProvider.AppPath, "Content", "Images", "Banners"); + _bannerPath = Path.Combine(_enviromentProvider.WebRoot, "Content", "Images", "Banners"); _diskProvider.CreateDirectory(_bannerPath); if (targetId > 0) diff --git a/NzbDrone.Core/Providers/TvDbProvider.cs b/NzbDrone.Core/Providers/TvDbProvider.cs index efa59ee26..da8465070 100644 --- a/NzbDrone.Core/Providers/TvDbProvider.cs +++ b/NzbDrone.Core/Providers/TvDbProvider.cs @@ -4,6 +4,7 @@ using System.Text.RegularExpressions; using NLog; using Ninject; +using NzbDrone.Common; using TvdbLib; using TvdbLib.Cache; using TvdbLib.Data; @@ -22,7 +23,7 @@ public class TvDbProvider public TvDbProvider(EnviromentProvider enviromentProvider) { _enviromentProvider = enviromentProvider; - _handler = new TvdbHandler(new XmlCacheProvider(_enviromentProvider.AppPath + @"\cache\tvdb"), TVDB_APIKEY); + _handler = new TvdbHandler(new XmlCacheProvider(_enviromentProvider.AppDataPath + @"\cache\tvdb"), TVDB_APIKEY); } public TvDbProvider() diff --git a/NzbDrone.Core/Providers/UpdateProvider.cs b/NzbDrone.Core/Providers/UpdateProvider.cs index eb70e710f..bc682c026 100644 --- a/NzbDrone.Core/Providers/UpdateProvider.cs +++ b/NzbDrone.Core/Providers/UpdateProvider.cs @@ -6,8 +6,10 @@ using System.Text.RegularExpressions; using NLog; using Ninject; +using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; +using DiskProvider = NzbDrone.Core.Providers.Core.DiskProvider; namespace NzbDrone.Core.Providers { diff --git a/NzbDrone.Update/Providers/UpdateProvider.cs b/NzbDrone.Update/Providers/UpdateProvider.cs index 1cc962ce9..b92f2d302 100644 --- a/NzbDrone.Update/Providers/UpdateProvider.cs +++ b/NzbDrone.Update/Providers/UpdateProvider.cs @@ -61,8 +61,8 @@ public void Start(string installationFolder) //Copy update folder on top of the existing folder - //Happy: Start Service, Process? //Happy: Cleanup + //Happy: Start Service, Process? //Sad: delete fucked up folder //Sad: restore backup diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index ccdd9000d..7919c0571 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -733,6 +733,10 @@ + + {F2BE0FDF-6E47-4827-A420-DD4EF82407F8} + NzbDrone.Common + {FF5EE3B6-913B-47CE-9CEB-11C51B4E1205} NzbDrone.Core diff --git a/NzbDrone.Web/Views/Shared/_Layout.cshtml b/NzbDrone.Web/Views/Shared/_Layout.cshtml index 029e1a298..ddffb4ded 100644 --- a/NzbDrone.Web/Views/Shared/_Layout.cshtml +++ b/NzbDrone.Web/Views/Shared/_Layout.cshtml @@ -1,5 +1,6 @@  @using Helpers; +@using NzbDrone.Common @@ -16,7 +17,6 @@ - @@ -30,7 +30,6 @@ - @MvcMiniProfiler.MiniProfiler.RenderIncludes() @RenderSection("HeaderContent", required: false) @@ -72,5 +71,21 @@ @(Html.Telerik().ScriptRegistrar().jQuery(false)) @RenderSection("Scripts", required: false) + @if (EnviromentProvider.IsProduction) + { + + } diff --git a/package.bat b/package.bat index ddfab2492..bf4355f5f 100644 --- a/package.bat +++ b/package.bat @@ -7,8 +7,7 @@ del nzbdrone*.zip /Q /F xcopy IISExpress %TARGET%\IISExpress /E /V /I /Y xcopy NzbDrone\bin\Release\*.* %TARGET%\ /E /V /I /Y -del %TARGET%\nlog.xml /Q /F -del %TARGET%\*.vshost.exe.* /Q /F + xcopy NzbDrone.Web\bin\*.* %TARGET%\NzbDrone.Web\bin\ /E /V /I /Y xcopy NzbDrone.Web\App_GlobalResources\*.* %TARGET%\NzbDrone.Web\App_GlobalResources\ /E /V /I /Y @@ -17,8 +16,7 @@ xcopy NzbDrone.Web\Scripts\*.* %TARGET%\NzbDrone.Web\Scripts\ /E /V /I /Y xcopy NzbDrone.Web\Views\*.* %TARGET%\NzbDrone.Web\Views\ /E /V /I /Y del %TARGET%\NzbDrone.Web\bin\*.xml /q -del %TARGET%\NzbDrone.Web\bin\ninject*.pdb /q -del %TARGET%\NzbDrone.Web\bin\Mvc*.pdb /q + xcopy NzbDrone.Web\log.config %TARGET%\NzbDrone.Web\ xcopy NzbDrone.Web\Global.asax %TARGET%\NzbDrone.Web\ @@ -27,6 +25,13 @@ xcopy NzbDrone.Web\web.config %TARGET%\NzbDrone.Web\ CD %PACKAGEROOT% + +del nlog.xml /Q /F /S +del *.vshost.exe.* /Q /F /S +del ninject*.pdb /Q /F /S +del ninject*.xml /Q /F /S +del Mvc*.pdb /Q /F /S + ..\Libraries\7zip\7za.exe a -tzip ..\NzbDrone.zip * CD ..