Merge branch 'kay.one' of github.com:NzbDrone/NzbDrone into markus

pull/3113/head
Mark McDowall 13 years ago
commit dd7dcf4db8

2
.gitignore vendored

@ -38,3 +38,5 @@ NzbDrone.Web/NzbDrone.Web.Publish.xml
*.sdf *.sdf
[Bb]anners [Bb]anners
*.orig *.orig
_rawPackage/
NzbDrone.zip

@ -97,7 +97,7 @@
<Naming2> <Naming2>
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong> <EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort> <EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateStaticReadonly" /> <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="PrivateStaticReadonly" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" /> <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" />
<PredefinedRule Inspect="True" Prefix="I" Suffix="" Style="AaBb" ElementKind="Interfaces" /> <PredefinedRule Inspect="True" Prefix="I" Suffix="" Style="AaBb" ElementKind="Interfaces" />
<PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" /> <PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" />

@ -7,23 +7,20 @@ namespace NzbDrone.Common
{ {
public class EnviromentProvider public class EnviromentProvider
{ {
public virtual String LogPath
{
get { return Environment.CurrentDirectory; }
}
public virtual bool IsUserInteractive #if DEBUG
{ private static readonly bool isInDebug = true;
get { return Environment.UserInteractive; } #else
} private static readonly bool isInDebug = false;
#endif
private static readonly string processName = Process.GetCurrentProcess().ProcessName.ToLower();
public static bool IsProduction public static bool IsProduction
{ {
get get
{ {
if (Debugger.IsAttached) return false; if (isInDebug || Debugger.IsAttached) return false;
var processName = Process.GetCurrentProcess().ProcessName.ToLower();
Console.WriteLine(processName); Console.WriteLine(processName);
if (processName.Contains("nunit")) return false; if (processName.Contains("nunit")) return false;
@ -34,6 +31,16 @@ namespace NzbDrone.Common
} }
} }
public virtual String LogPath
{
get { return Environment.CurrentDirectory; }
}
public virtual bool IsUserInteractive
{
get { return Environment.UserInteractive; }
}
public virtual string ApplicationPath public virtual string ApplicationPath
{ {
get get
@ -60,6 +67,26 @@ namespace NzbDrone.Common
} }
} }
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 public virtual string StartUpPath
{ {
get get
@ -68,6 +95,30 @@ namespace NzbDrone.Common
} }
} }
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) private static bool ContainsIIS(DirectoryInfo dir)
{ {
return dir.GetDirectories("iisexpress").Length != 0; return dir.GetDirectories("iisexpress").Length != 0;

@ -4,12 +4,14 @@ using AutoMoq;
using FizzWare.NBuilder; using FizzWare.NBuilder;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.Jobs; using NzbDrone.Core.Providers.Jobs;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using DiskProvider = NzbDrone.Core.Providers.Core.DiskProvider;
namespace NzbDrone.Core.Test.JobTests namespace NzbDrone.Core.Test.JobTests
{ {
@ -90,7 +92,7 @@ namespace NzbDrone.Core.Test.JobTests
var fakeSeries = Builder<Series>.CreateListOfSize(10) var fakeSeries = Builder<Series>.CreateListOfSize(10)
.Build(); .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); var mocker = new AutoMoqer(MockBehavior.Strict);
mocker.Resolve<EnviromentProvider>(); mocker.Resolve<EnviromentProvider>();

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using TvdbLib.Data; using TvdbLib.Data;

@ -3,6 +3,7 @@ using AutoMoq;
using FluentAssertions; using FluentAssertions;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;

@ -4,10 +4,12 @@ using AutoMoq;
using FluentAssertions; using FluentAssertions;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using DiskProvider = NzbDrone.Core.Providers.Core.DiskProvider;
namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
{ {

@ -4,6 +4,7 @@ using System.Data.Common;
using System.Data.SqlServerCe; using System.Data.SqlServerCe;
using System.IO; using System.IO;
using MvcMiniProfiler.Data; using MvcMiniProfiler.Data;
using NzbDrone.Common;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using PetaPoco; using PetaPoco;
@ -11,11 +12,10 @@ namespace NzbDrone.Core.Datastore
{ {
public static class Connection 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() static Connection()
{ {
if (!AppDataPath.Exists) AppDataPath.Create();
Database.Mapper = new CustomeMapper(); Database.Mapper = new CustomeMapper();
} }
@ -30,7 +30,7 @@ namespace NzbDrone.Core.Datastore
{ {
get get
{ {
return GetConnectionString(Path.Combine(AppDataPath.FullName, "nzbdrone.sdf")); return GetConnectionString(Path.Combine(_enviromentProvider.AppDataPath, "nzbdrone.sdf"));
} }
} }
@ -38,7 +38,7 @@ namespace NzbDrone.Core.Datastore
{ {
get get
{ {
return GetConnectionString(Path.Combine(AppDataPath.FullName, "log.sdf")); return GetConnectionString(Path.Combine(_enviromentProvider.AppDataPath, "log.sdf"));
} }
} }

@ -2,6 +2,7 @@
using Ninject; using Ninject;
using NLog; using NLog;
using NLog.Config; using NLog.Config;
using NzbDrone.Common;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
namespace NzbDrone.Core.Instrumentation namespace NzbDrone.Core.Instrumentation
@ -16,7 +17,7 @@ namespace NzbDrone.Core.Instrumentation
LogManager.ThrowExceptions = false; 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.Web.MvcApplication");
Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Core.CentralDispatch"); Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Core.CentralDispatch");

@ -219,7 +219,6 @@
<Compile Include="Model\Xbmc\IconType.cs" /> <Compile Include="Model\Xbmc\IconType.cs" />
<Compile Include="Providers\Converting\AtomicParsleyProvider.cs" /> <Compile Include="Providers\Converting\AtomicParsleyProvider.cs" />
<Compile Include="Providers\Converting\HandbrakeProvider.cs" /> <Compile Include="Providers\Converting\HandbrakeProvider.cs" />
<Compile Include="Providers\EnviromentProvider.cs" />
<Compile Include="Providers\Core\ConfigFileProvider.cs" /> <Compile Include="Providers\Core\ConfigFileProvider.cs" />
<Compile Include="Providers\Core\UdpProvider.cs" /> <Compile Include="Providers\Core\UdpProvider.cs" />
<Compile Include="Providers\ExternalNotification\Twitter.cs" /> <Compile Include="Providers\ExternalNotification\Twitter.cs" />

@ -1,17 +1,15 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
using NzbDrone.Common;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
namespace NzbDrone.Core.Providers.Core namespace NzbDrone.Core.Providers.Core
{ {
public class ConfigFileProvider 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 public string ConfigFile
{ {
@ -112,16 +110,7 @@ namespace NzbDrone.Core.Providers.Core
public virtual void CreateDefaultConfigFile() public virtual void CreateDefaultConfigFile()
{ {
//Create the config file here
Directory.CreateDirectory(Path.Combine(new EnviromentProvider().AppPath, "App_Data"));
if (!File.Exists(ConfigFile)) if (!File.Exists(ConfigFile))
{
WriteDefaultConfig();
}
}
public virtual void WriteDefaultConfig()
{ {
var xDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes")); var xDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
@ -131,3 +120,4 @@ namespace NzbDrone.Core.Providers.Core
} }
} }
} }
}

@ -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();
}
}
}
}

@ -4,9 +4,11 @@ using System.IO;
using System.Linq; using System.Linq;
using Ninject; using Ninject;
using NLog; using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using DiskProvider = NzbDrone.Core.Providers.Core.DiskProvider;
namespace NzbDrone.Core.Providers.Jobs namespace NzbDrone.Core.Providers.Jobs
{ {
@ -49,7 +51,7 @@ namespace NzbDrone.Core.Providers.Jobs
{ {
Logger.Debug("Starting banner download job"); 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); _diskProvider.CreateDirectory(_bannerPath);
if (targetId > 0) if (targetId > 0)

@ -4,6 +4,7 @@ using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using NLog; using NLog;
using Ninject; using Ninject;
using NzbDrone.Common;
using TvdbLib; using TvdbLib;
using TvdbLib.Cache; using TvdbLib.Cache;
using TvdbLib.Data; using TvdbLib.Data;
@ -22,7 +23,7 @@ namespace NzbDrone.Core.Providers
public TvDbProvider(EnviromentProvider enviromentProvider) public TvDbProvider(EnviromentProvider enviromentProvider)
{ {
_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() public TvDbProvider()

@ -6,8 +6,10 @@ using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using NLog; using NLog;
using Ninject; using Ninject;
using NzbDrone.Common;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using DiskProvider = NzbDrone.Core.Providers.Core.DiskProvider;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {

@ -61,8 +61,8 @@ namespace NzbDrone.Update.Providers
//Copy update folder on top of the existing folder //Copy update folder on top of the existing folder
//Happy: Start Service, Process?
//Happy: Cleanup //Happy: Cleanup
//Happy: Start Service, Process?
//Sad: delete fucked up folder //Sad: delete fucked up folder
//Sad: restore backup //Sad: restore backup

@ -733,6 +733,10 @@
<Folder Include="App_Data\" /> <Folder Include="App_Data\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NzbDrone.Common\NzbDrone.Common.csproj">
<Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project>
<Name>NzbDrone.Common</Name>
</ProjectReference>
<ProjectReference Include="..\NzbDrone.Core\NzbDrone.Core.csproj"> <ProjectReference Include="..\NzbDrone.Core\NzbDrone.Core.csproj">
<Project>{FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}</Project> <Project>{FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}</Project>
<Name>NzbDrone.Core</Name> <Name>NzbDrone.Core</Name>

@ -1,5 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@using Helpers; @using Helpers;
@using NzbDrone.Common
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"> <head runat="server">
<link rel="SHORTCUT ICON" href="../../favicon.ico" /> <link rel="SHORTCUT ICON" href="../../favicon.ico" />
@ -16,7 +17,6 @@
<link type="text/css" rel="stylesheet" href="/Content/overrides.css" /> <link type="text/css" rel="stylesheet" href="/Content/overrides.css" />
<link type="text/css" rel="stylesheet" href="/Content/Menu.css" /> <link type="text/css" rel="stylesheet" href="/Content/Menu.css" />
<link type="text/css" rel="stylesheet" href="/Content/Slider.css" /> <link type="text/css" rel="stylesheet" href="/Content/Slider.css" />
<script type="text/javascript" src="/Scripts/Plugins/jquery-1.6.3.min.js"></script> <script type="text/javascript" src="/Scripts/Plugins/jquery-1.6.3.min.js"></script>
<script type="text/javascript" src="/Scripts/Plugins/jquery-ui-1.8.16.min.js"></script> <script type="text/javascript" src="/Scripts/Plugins/jquery-ui-1.8.16.min.js"></script>
<script type="text/javascript" src="/Scripts/Plugins/MicrosoftAjax.js"></script> <script type="text/javascript" src="/Scripts/Plugins/MicrosoftAjax.js"></script>
@ -30,7 +30,6 @@
<script type="text/javascript" src="/Scripts/autocomplete.js"></script> <script type="text/javascript" src="/Scripts/autocomplete.js"></script>
<script type="text/javascript" src="/Scripts/addSeries.js"></script> <script type="text/javascript" src="/Scripts/addSeries.js"></script>
<script type="text/javascript" src="/Scripts/slider.js"></script> <script type="text/javascript" src="/Scripts/slider.js"></script>
@MvcMiniProfiler.MiniProfiler.RenderIncludes() @MvcMiniProfiler.MiniProfiler.RenderIncludes()
@RenderSection("HeaderContent", required: false) @RenderSection("HeaderContent", required: false)
</head> </head>
@ -72,5 +71,21 @@
@(Html.Telerik().ScriptRegistrar().jQuery(false)) @(Html.Telerik().ScriptRegistrar().jQuery(false))
@RenderSection("Scripts", required: false) @RenderSection("Scripts", required: false)
<script type="text/javascript" src="/Scripts/Notification.js"></script> <script type="text/javascript" src="/Scripts/Notification.js"></script>
@if (EnviromentProvider.IsProduction)
{
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-8318723-7']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
}
</body> </body>
</html> </html>

@ -7,8 +7,7 @@ del nzbdrone*.zip /Q /F
xcopy IISExpress %TARGET%\IISExpress /E /V /I /Y xcopy IISExpress %TARGET%\IISExpress /E /V /I /Y
xcopy NzbDrone\bin\Release\*.* %TARGET%\ /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\bin\*.* %TARGET%\NzbDrone.Web\bin\ /E /V /I /Y
xcopy NzbDrone.Web\App_GlobalResources\*.* %TARGET%\NzbDrone.Web\App_GlobalResources\ /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 xcopy NzbDrone.Web\Views\*.* %TARGET%\NzbDrone.Web\Views\ /E /V /I /Y
del %TARGET%\NzbDrone.Web\bin\*.xml /q 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\log.config %TARGET%\NzbDrone.Web\
xcopy NzbDrone.Web\Global.asax %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% 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 * ..\Libraries\7zip\7za.exe a -tzip ..\NzbDrone.zip *
CD .. CD ..

Loading…
Cancel
Save