mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
fixing update for vnext.
This commit is contained in:
parent
2001e5f502
commit
80c996c216
@ -7,11 +7,13 @@
|
|||||||
using NzbDrone.Api.Mapping;
|
using NzbDrone.Api.Mapping;
|
||||||
using NzbDrone.Api.RootFolders;
|
using NzbDrone.Api.RootFolders;
|
||||||
using NzbDrone.Api.Series;
|
using NzbDrone.Api.Series;
|
||||||
|
using NzbDrone.Api.Update;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Indexers;
|
using NzbDrone.Core.Indexers;
|
||||||
using NzbDrone.Core.Organizer;
|
using NzbDrone.Core.Organizer;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
using NzbDrone.Core.RootFolders;
|
using NzbDrone.Core.RootFolders;
|
||||||
|
using NzbDrone.Core.Update;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Api.Test.MappingTests
|
namespace NzbDrone.Api.Test.MappingTests
|
||||||
@ -28,6 +30,7 @@ public class ResourceMappingFixture : TestBase
|
|||||||
[TestCase(typeof(ParsedEpisodeInfo), typeof(ReleaseResource))]
|
[TestCase(typeof(ParsedEpisodeInfo), typeof(ReleaseResource))]
|
||||||
[TestCase(typeof(DownloadDecision), typeof(ReleaseResource))]
|
[TestCase(typeof(DownloadDecision), typeof(ReleaseResource))]
|
||||||
[TestCase(typeof(Core.History.History), typeof(HistoryResource))]
|
[TestCase(typeof(Core.History.History), typeof(HistoryResource))]
|
||||||
|
[TestCase(typeof(UpdatePackage), typeof(UpdateResource))]
|
||||||
public void matching_fields(Type modelType, Type resourceType)
|
public void matching_fields(Type modelType, Type resourceType)
|
||||||
{
|
{
|
||||||
MappingValidation.ValidateMapping(modelType, resourceType);
|
MappingValidation.ValidateMapping(modelType, resourceType);
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
using NzbDrone.Api.Episodes;
|
using NzbDrone.Api.Episodes;
|
||||||
using NzbDrone.Api.History;
|
using NzbDrone.Api.History;
|
||||||
using NzbDrone.Api.Missing;
|
using NzbDrone.Api.Missing;
|
||||||
using NzbDrone.Api.QualityProfiles;
|
using NzbDrone.Api.Qualities;
|
||||||
using NzbDrone.Api.QualityType;
|
|
||||||
using NzbDrone.Api.Resolvers;
|
using NzbDrone.Api.Resolvers;
|
||||||
using NzbDrone.Api.Series;
|
using NzbDrone.Api.Series;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
@ -20,11 +19,11 @@ public static class AutomapperBootstraper
|
|||||||
public static void InitializeAutomapper()
|
public static void InitializeAutomapper()
|
||||||
{
|
{
|
||||||
//QualityProfiles
|
//QualityProfiles
|
||||||
Mapper.CreateMap<QualityProfile, QualityProfileModel>()
|
Mapper.CreateMap<QualityProfile, QualityProfileResource>()
|
||||||
.ForMember(dest => dest.Qualities,
|
.ForMember(dest => dest.Qualities,
|
||||||
opt => opt.ResolveUsing<AllowedToQualitiesResolver>().FromMember(src => src.Allowed));
|
opt => opt.ResolveUsing<AllowedToQualitiesResolver>().FromMember(src => src.Allowed));
|
||||||
|
|
||||||
Mapper.CreateMap<QualityProfileModel, QualityProfile>()
|
Mapper.CreateMap<QualityProfileResource, QualityProfile>()
|
||||||
.ForMember(dest => dest.Allowed,
|
.ForMember(dest => dest.Allowed,
|
||||||
opt => opt.ResolveUsing<QualitiesToAllowedResolver>().FromMember(src => src.Qualities));
|
opt => opt.ResolveUsing<QualitiesToAllowedResolver>().FromMember(src => src.Qualities));
|
||||||
|
|
||||||
|
@ -135,10 +135,10 @@
|
|||||||
<Compile Include="Exceptions\InvalidApiKeyException.cs" />
|
<Compile Include="Exceptions\InvalidApiKeyException.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="NzbDroneApiModule.cs" />
|
<Compile Include="NzbDroneApiModule.cs" />
|
||||||
<Compile Include="QualityProfiles\QualityProfileModel.cs" />
|
<Compile Include="Qualities\QualityProfileResource.cs" />
|
||||||
<Compile Include="QualityProfiles\QualityProfilesModule.cs" />
|
<Compile Include="Qualities\QualityProfilesModule.cs" />
|
||||||
<Compile Include="QualityType\QualitySizeResource.cs" />
|
<Compile Include="Qualities\QualitySizeResource.cs" />
|
||||||
<Compile Include="QualityType\QualitySizeModule.cs" />
|
<Compile Include="Qualities\QualitySizeModule.cs" />
|
||||||
<Compile Include="Extensions\RequestExtensions.cs" />
|
<Compile Include="Extensions\RequestExtensions.cs" />
|
||||||
<Compile Include="Resolvers\AllowedToQualitiesResolver.cs" />
|
<Compile Include="Resolvers\AllowedToQualitiesResolver.cs" />
|
||||||
<Compile Include="Resolvers\QualitiesToAllowedResolver.cs" />
|
<Compile Include="Resolvers\QualitiesToAllowedResolver.cs" />
|
||||||
@ -149,6 +149,7 @@
|
|||||||
<Compile Include="SignalR\SignalrDependencyResolver.cs" />
|
<Compile Include="SignalR\SignalrDependencyResolver.cs" />
|
||||||
<Compile Include="SignalR\NzbDronePersistentConnection.cs" />
|
<Compile Include="SignalR\NzbDronePersistentConnection.cs" />
|
||||||
<Compile Include="TinyIoCNancyBootstrapper.cs" />
|
<Compile Include="TinyIoCNancyBootstrapper.cs" />
|
||||||
|
<Compile Include="Update\UpdateModule.cs" />
|
||||||
<Compile Include="Validation\IdValidationRule.cs" />
|
<Compile Include="Validation\IdValidationRule.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace NzbDrone.Api.QualityProfiles
|
namespace NzbDrone.Api.Qualities
|
||||||
{
|
{
|
||||||
public class QualityProfileModel
|
public class QualityProfileResource
|
||||||
{
|
{
|
||||||
public Int32 Id { get; set; }
|
public Int32 Id { get; set; }
|
||||||
public String Name { get; set; }
|
public String Name { get; set; }
|
@ -4,7 +4,7 @@
|
|||||||
using NzbDrone.Api.Extensions;
|
using NzbDrone.Api.Extensions;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace NzbDrone.Api.QualityProfiles
|
namespace NzbDrone.Api.Qualities
|
||||||
{
|
{
|
||||||
public class QualityProfilesModule : NzbDroneApiModule
|
public class QualityProfilesModule : NzbDroneApiModule
|
||||||
{
|
{
|
||||||
@ -23,19 +23,19 @@ public QualityProfilesModule(QualityProfileService qualityProvider)
|
|||||||
private Response OnGet()
|
private Response OnGet()
|
||||||
{
|
{
|
||||||
var profiles = _qualityProvider.All();
|
var profiles = _qualityProvider.All();
|
||||||
return Mapper.Map<List<QualityProfile>, List<QualityProfileModel>>(profiles).AsResponse();
|
return Mapper.Map<List<QualityProfile>, List<QualityProfileResource>>(profiles).AsResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response OnGet(int id)
|
private Response OnGet(int id)
|
||||||
{
|
{
|
||||||
var profile = _qualityProvider.Get(id);
|
var profile = _qualityProvider.Get(id);
|
||||||
return Mapper.Map<QualityProfile, QualityProfileModel>(profile).AsResponse();
|
return Mapper.Map<QualityProfile, QualityProfileResource>(profile).AsResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response OnPost()
|
private Response OnPost()
|
||||||
{
|
{
|
||||||
var request = Request.Body.FromJson<QualityProfileModel>();
|
var request = Request.Body.FromJson<QualityProfileResource>();
|
||||||
var profile = Mapper.Map<QualityProfileModel, QualityProfile>(request);
|
var profile = Mapper.Map<QualityProfileResource, QualityProfile>(request);
|
||||||
request.Id = _qualityProvider.Add(profile).Id;
|
request.Id = _qualityProvider.Add(profile).Id;
|
||||||
|
|
||||||
return request.AsResponse();
|
return request.AsResponse();
|
||||||
@ -44,8 +44,8 @@ private Response OnPost()
|
|||||||
//Update
|
//Update
|
||||||
private Response OnPut()
|
private Response OnPut()
|
||||||
{
|
{
|
||||||
var request = Request.Body.FromJson<QualityProfileModel>();
|
var request = Request.Body.FromJson<QualityProfileResource>();
|
||||||
var profile = Mapper.Map<QualityProfileModel, QualityProfile>(request);
|
var profile = Mapper.Map<QualityProfileResource, QualityProfile>(request);
|
||||||
_qualityProvider.Update(profile);
|
_qualityProvider.Update(profile);
|
||||||
|
|
||||||
return request.AsResponse();
|
return request.AsResponse();
|
@ -5,7 +5,7 @@
|
|||||||
using NzbDrone.Api.Extensions;
|
using NzbDrone.Api.Extensions;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace NzbDrone.Api.QualityType
|
namespace NzbDrone.Api.Qualities
|
||||||
{
|
{
|
||||||
public class QualitySizeModule : NzbDroneApiModule
|
public class QualitySizeModule : NzbDroneApiModule
|
||||||
{
|
{
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using NzbDrone.Api.REST;
|
using NzbDrone.Api.REST;
|
||||||
|
|
||||||
namespace NzbDrone.Api.QualityType
|
namespace NzbDrone.Api.Qualities
|
||||||
{
|
{
|
||||||
public class QualitySizeResource : RestResource
|
public class QualitySizeResource : RestResource
|
||||||
{
|
{
|
@ -2,7 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using NzbDrone.Api.QualityProfiles;
|
using NzbDrone.Api.Qualities;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace NzbDrone.Api.Resolvers
|
namespace NzbDrone.Api.Resolvers
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using NzbDrone.Api.QualityProfiles;
|
|
||||||
|
|
||||||
namespace NzbDrone.Api.Resolvers
|
namespace NzbDrone.Api.Resolvers
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using NzbDrone.Api.QualityProfiles;
|
using NzbDrone.Api.Qualities;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace NzbDrone.Api.Resolvers
|
namespace NzbDrone.Api.Resolvers
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
|
39
NzbDrone.Api/Update/UpdateModule.cs
Normal file
39
NzbDrone.Api/Update/UpdateModule.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using NzbDrone.Api.REST;
|
||||||
|
using NzbDrone.Core.Update;
|
||||||
|
using NzbDrone.Api.Mapping;
|
||||||
|
|
||||||
|
namespace NzbDrone.Api.Update
|
||||||
|
{
|
||||||
|
public class UpdateModule : NzbDroneRestModule<UpdateResource>
|
||||||
|
{
|
||||||
|
private readonly IUpdateService _updateService;
|
||||||
|
|
||||||
|
public UpdateModule(IUpdateService updateService)
|
||||||
|
{
|
||||||
|
_updateService = updateService;
|
||||||
|
GetResourceAll = GetAvailableUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<UpdateResource> GetAvailableUpdate()
|
||||||
|
{
|
||||||
|
var update = _updateService.AvailableUpdate();
|
||||||
|
var response = new List<UpdateResource>();
|
||||||
|
|
||||||
|
if (update != null)
|
||||||
|
{
|
||||||
|
response.Add(update.InjectTo<UpdateResource>());
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UpdateResource : RestResource
|
||||||
|
{
|
||||||
|
public Version Version { get; set; }
|
||||||
|
public String FileName { get; set; }
|
||||||
|
public String Url { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -107,12 +107,6 @@ public void GetUpdateClientExePath()
|
|||||||
GetEnvironmentProvider().GetUpdateClientExePath().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone.Update.exe");
|
GetEnvironmentProvider().GetUpdateClientExePath().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone.Update.exe");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void GetSandboxLogFolder()
|
|
||||||
{
|
|
||||||
GetEnvironmentProvider().GetSandboxLogFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\UpdateLogs\");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void GetUpdateLogFolder()
|
public void GetUpdateLogFolder()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using NLog;
|
||||||
|
using NLog.Config;
|
||||||
|
using NLog.LayoutRenderers;
|
||||||
|
|
||||||
|
namespace NzbDrone.Common.Instrumentation
|
||||||
|
{
|
||||||
|
[ThreadAgnostic]
|
||||||
|
[LayoutRenderer("appLog")]
|
||||||
|
public class ApplicationLogLayoutRenderer : LayoutRenderer
|
||||||
|
{
|
||||||
|
private readonly string _appData;
|
||||||
|
|
||||||
|
public ApplicationLogLayoutRenderer()
|
||||||
|
{
|
||||||
|
_appData = Path.Combine(new EnvironmentProvider().GetLogFolder(), "nzbdrone.txt");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Append(StringBuilder builder, LogEventInfo logEvent)
|
||||||
|
{
|
||||||
|
builder.Append(_appData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using NLog;
|
||||||
|
using NLog.Config;
|
||||||
|
using NLog.LayoutRenderers;
|
||||||
|
|
||||||
|
namespace NzbDrone.Common.Instrumentation
|
||||||
|
{
|
||||||
|
[ThreadAgnostic]
|
||||||
|
[LayoutRenderer("dirSeparator")]
|
||||||
|
public class DirSeparatorLayoutRenderer : LayoutRenderer
|
||||||
|
{
|
||||||
|
|
||||||
|
protected override void Append(StringBuilder builder, LogEventInfo logEvent)
|
||||||
|
{
|
||||||
|
builder.Append(Path.DirectorySeparatorChar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
NzbDrone.Common/Instrumentation/UpdateLogLayoutRenderer.cs
Normal file
27
NzbDrone.Common/Instrumentation/UpdateLogLayoutRenderer.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using NLog;
|
||||||
|
using NLog.Config;
|
||||||
|
using NLog.LayoutRenderers;
|
||||||
|
|
||||||
|
namespace NzbDrone.Common.Instrumentation
|
||||||
|
{
|
||||||
|
[ThreadAgnostic]
|
||||||
|
[LayoutRenderer("updateLog")]
|
||||||
|
public class UpdateLogLayoutRenderer : LayoutRenderer
|
||||||
|
{
|
||||||
|
private readonly string _appData;
|
||||||
|
|
||||||
|
public UpdateLogLayoutRenderer()
|
||||||
|
{
|
||||||
|
_appData = Path.Combine(new EnvironmentProvider().GetUpdateLogFolder(), DateTime.Now.ToString("yy.MM.d-HH.mm"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Append(StringBuilder builder, LogEventInfo logEvent)
|
||||||
|
{
|
||||||
|
builder.Append(_appData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -11,11 +11,11 @@ namespace NzbDrone.Common.Instrumentation
|
|||||||
[LayoutRenderer("version")]
|
[LayoutRenderer("version")]
|
||||||
public class VersionLayoutRenderer : LayoutRenderer
|
public class VersionLayoutRenderer : LayoutRenderer
|
||||||
{
|
{
|
||||||
private static readonly string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
private static readonly string Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||||
|
|
||||||
protected override void Append(StringBuilder builder, LogEventInfo logEvent)
|
protected override void Append(StringBuilder builder, LogEventInfo logEvent)
|
||||||
{
|
{
|
||||||
builder.Append(version);
|
builder.Append(Version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,9 @@
|
|||||||
<Compile Include="EnsureThat\Resources\ExceptionMessages.Designer.cs" />
|
<Compile Include="EnsureThat\Resources\ExceptionMessages.Designer.cs" />
|
||||||
<Compile Include="EnsureThat\StringExtensions.cs" />
|
<Compile Include="EnsureThat\StringExtensions.cs" />
|
||||||
<Compile Include="EnsureThat\TypeParam.cs" />
|
<Compile Include="EnsureThat\TypeParam.cs" />
|
||||||
|
<Compile Include="Instrumentation\ApplicationLogLayoutRenderer.cs" />
|
||||||
|
<Compile Include="Instrumentation\DirSeparatorLayoutRenderer.cs" />
|
||||||
|
<Compile Include="Instrumentation\UpdateLogLayoutRenderer.cs" />
|
||||||
<Compile Include="Serializer\Json.cs" />
|
<Compile Include="Serializer\Json.cs" />
|
||||||
<Compile Include="Messaging\CommandCompletedEvent.cs" />
|
<Compile Include="Messaging\CommandCompletedEvent.cs" />
|
||||||
<Compile Include="Messaging\CommandStartedEvent.cs" />
|
<Compile Include="Messaging\CommandStartedEvent.cs" />
|
||||||
|
@ -5,7 +5,6 @@ namespace NzbDrone.Common
|
|||||||
{
|
{
|
||||||
public static class PathExtensions
|
public static class PathExtensions
|
||||||
{
|
{
|
||||||
private static readonly string APP_DATA = "App_Data" + Path.DirectorySeparatorChar;
|
|
||||||
private static readonly string APP_CONFIG_FILE = "config.xml";
|
private static readonly string APP_CONFIG_FILE = "config.xml";
|
||||||
private static readonly string NZBDRONE_DB = "nzbdrone.db";
|
private static readonly string NZBDRONE_DB = "nzbdrone.db";
|
||||||
private static readonly string BACKUP_ZIP_FILE = "NzbDrone_Backup.zip";
|
private static readonly string BACKUP_ZIP_FILE = "NzbDrone_Backup.zip";
|
||||||
@ -57,12 +56,17 @@ public static string GetActualCasing(this string filename)
|
|||||||
|
|
||||||
public static string GetAppDataPath(this IEnvironmentProvider environmentProvider)
|
public static string GetAppDataPath(this IEnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(environmentProvider.WorkingDirectory, APP_DATA);
|
return environmentProvider.WorkingDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetLogFolder(this IEnvironmentProvider environmentProvider)
|
||||||
|
{
|
||||||
|
return Path.Combine(environmentProvider.GetAppDataPath(), "logs");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetConfigPath(this IEnvironmentProvider environmentProvider)
|
public static string GetConfigPath(this IEnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(environmentProvider.WorkingDirectory, APP_CONFIG_FILE);
|
return Path.Combine(environmentProvider.GetAppDataPath(), APP_CONFIG_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetMediaCoverPath(this IEnvironmentProvider environmentProvider)
|
public static string GetMediaCoverPath(this IEnvironmentProvider environmentProvider)
|
||||||
@ -72,7 +76,7 @@ public static string GetMediaCoverPath(this IEnvironmentProvider environmentProv
|
|||||||
|
|
||||||
public static string GetUpdateLogFolder(this IEnvironmentProvider environmentProvider)
|
public static string GetUpdateLogFolder(this IEnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(environmentProvider.WorkingDirectory, UPDATE_LOG_FOLDER_NAME);
|
return Path.Combine(environmentProvider.GetAppDataPath(), UPDATE_LOG_FOLDER_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetUpdateSandboxFolder(this IEnvironmentProvider environmentProvider)
|
public static string GetUpdateSandboxFolder(this IEnvironmentProvider environmentProvider)
|
||||||
@ -100,11 +104,6 @@ public static string GetUpdateClientExePath(this IEnvironmentProvider environmen
|
|||||||
return Path.Combine(environmentProvider.GetUpdateSandboxFolder(), UPDATE_CLIENT_EXE);
|
return Path.Combine(environmentProvider.GetUpdateSandboxFolder(), UPDATE_CLIENT_EXE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetSandboxLogFolder(this IEnvironmentProvider environmentProvider)
|
|
||||||
{
|
|
||||||
return Path.Combine(environmentProvider.GetUpdateSandboxFolder(), UPDATE_LOG_FOLDER_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetConfigBackupFile(this IEnvironmentProvider environmentProvider)
|
public static string GetConfigBackupFile(this IEnvironmentProvider environmentProvider)
|
||||||
{
|
{
|
||||||
return Path.Combine(environmentProvider.GetAppDataPath(), BACKUP_ZIP_FILE);
|
return Path.Combine(environmentProvider.GetAppDataPath(), BACKUP_ZIP_FILE);
|
||||||
|
@ -32,6 +32,7 @@ public static bool IsSimpleType(this Type type)
|
|||||||
|| type.IsEnum
|
|| type.IsEnum
|
||||||
|| type == typeof(string)
|
|| type == typeof(string)
|
||||||
|| type == typeof(DateTime)
|
|| type == typeof(DateTime)
|
||||||
|
|| type == typeof(Version)
|
||||||
|| type == typeof(Decimal);
|
|| type == typeof(Decimal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using NzbDrone.Core.Update;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.UpdateTests
|
namespace NzbDrone.Core.Test.UpdateTests
|
||||||
{
|
{
|
||||||
|
@ -167,7 +167,7 @@ public string XbmcPassword
|
|||||||
|
|
||||||
public string UpdateUrl
|
public string UpdateUrl
|
||||||
{
|
{
|
||||||
get { return GetValue("UpdateUrl", "http://update.nzbdrone.com/_release/"); }
|
get { return GetValue("UpdateUrl", "http://update.nzbdrone.com/vnext/"); }
|
||||||
set { SetValue("UpdateUrl", value); }
|
set { SetValue("UpdateUrl", value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,10 +45,7 @@ private void ExecuteCommands()
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var commandType = Type.GetType(task.TypeName);
|
_messageAggregator.PublishCommand(task.TypeName);
|
||||||
var command = (ICommand)Activator.CreateInstance(commandType);
|
|
||||||
|
|
||||||
_messageAggregator.PublishCommand(command);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
using NzbDrone.Core.Lifecycle;
|
using NzbDrone.Core.Lifecycle;
|
||||||
using NzbDrone.Core.MediaFiles.Commands;
|
using NzbDrone.Core.MediaFiles.Commands;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
|
using NzbDrone.Core.Update.Commands;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Jobs
|
namespace NzbDrone.Core.Jobs
|
||||||
{
|
{
|
||||||
@ -39,7 +40,8 @@ public void Handle(ApplicationStartedEvent message)
|
|||||||
new ScheduledTask{ Interval = 25, TypeName = typeof(RssSyncCommand).FullName},
|
new ScheduledTask{ Interval = 25, TypeName = typeof(RssSyncCommand).FullName},
|
||||||
new ScheduledTask{ Interval = 12*60, TypeName = typeof(UpdateXemMappings).FullName},
|
new ScheduledTask{ Interval = 12*60, TypeName = typeof(UpdateXemMappings).FullName},
|
||||||
new ScheduledTask{ Interval = 6*60, TypeName = typeof(DiskScanCommand).FullName},
|
new ScheduledTask{ Interval = 6*60, TypeName = typeof(DiskScanCommand).FullName},
|
||||||
new ScheduledTask{ Interval = 1, TypeName = typeof(DownloadedEpisodesScanCommand).FullName}
|
new ScheduledTask{ Interval = 1, TypeName = typeof(DownloadedEpisodesScanCommand).FullName},
|
||||||
|
new ScheduledTask{ Interval = 15, TypeName = typeof(ApplicationUpdateCommand).FullName}
|
||||||
};
|
};
|
||||||
|
|
||||||
var currentTasks = _scheduledTaskRepository.All();
|
var currentTasks = _scheduledTaskRepository.All();
|
||||||
|
@ -7,18 +7,17 @@
|
|||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Common.Messaging;
|
using NzbDrone.Common.Messaging;
|
||||||
using NzbDrone.Core.Update;
|
|
||||||
using NzbDrone.Core.Update.Commands;
|
using NzbDrone.Core.Update.Commands;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Update
|
namespace NzbDrone.Core.Update
|
||||||
{
|
{
|
||||||
public interface IUpdateService
|
public interface IUpdateService : IExecute<ApplicationUpdateCommand>
|
||||||
{
|
{
|
||||||
Dictionary<DateTime, string> GetUpdateLogFiles();
|
Dictionary<DateTime, string> GetUpdateLogFiles();
|
||||||
}
|
UpdatePackage AvailableUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UpdateService : IUpdateService, IExecute<ApplicationUpdateCommand>
|
public class UpdateService : IUpdateService
|
||||||
{
|
{
|
||||||
private readonly IUpdatePackageProvider _updatePackageProvider;
|
private readonly IUpdatePackageProvider _updatePackageProvider;
|
||||||
private readonly IEnvironmentProvider _environmentProvider;
|
private readonly IEnvironmentProvider _environmentProvider;
|
||||||
@ -31,8 +30,10 @@ public class UpdateService : IUpdateService, IExecute<ApplicationUpdateCommand>
|
|||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
|
|
||||||
public UpdateService(IUpdatePackageProvider updatePackageProvider, IEnvironmentProvider environmentProvider, IDiskProvider diskProvider,
|
public UpdateService(IUpdatePackageProvider updatePackageProvider, IEnvironmentProvider environmentProvider,
|
||||||
IHttpProvider httpProvider, IConfigFileProvider configFileProvider, ArchiveProvider archiveProvider, IProcessProvider processProvider, Logger logger)
|
IDiskProvider diskProvider,
|
||||||
|
IHttpProvider httpProvider, IConfigFileProvider configFileProvider,
|
||||||
|
ArchiveProvider archiveProvider, IProcessProvider processProvider, Logger logger)
|
||||||
{
|
{
|
||||||
_updatePackageProvider = updatePackageProvider;
|
_updatePackageProvider = updatePackageProvider;
|
||||||
_environmentProvider = environmentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
@ -47,12 +48,14 @@ public UpdateService(IUpdatePackageProvider updatePackageProvider, IEnvironmentP
|
|||||||
|
|
||||||
private void InstallUpdate(UpdatePackage updatePackage)
|
private void InstallUpdate(UpdatePackage updatePackage)
|
||||||
{
|
{
|
||||||
var packageDestination = Path.Combine(_environmentProvider.GetUpdateSandboxFolder(), updatePackage.FileName);
|
var updateSandboxFolder = _environmentProvider.GetUpdateSandboxFolder();
|
||||||
|
|
||||||
if (_diskProvider.FolderExists(_environmentProvider.GetUpdateSandboxFolder()))
|
var packageDestination = Path.Combine(updateSandboxFolder, updatePackage.FileName);
|
||||||
|
|
||||||
|
if (_diskProvider.FolderExists(updateSandboxFolder))
|
||||||
{
|
{
|
||||||
_logger.Info("Deleting old update files");
|
_logger.Info("Deleting old update files");
|
||||||
_diskProvider.DeleteFolder(_environmentProvider.GetUpdateSandboxFolder(), true);
|
_diskProvider.DeleteFolder(updateSandboxFolder, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Info("Downloading update package from [{0}] to [{1}]", updatePackage.Url, packageDestination);
|
_logger.Info("Downloading update package from [{0}] to [{1}]", updatePackage.Url, packageDestination);
|
||||||
@ -60,11 +63,12 @@ private void InstallUpdate(UpdatePackage updatePackage)
|
|||||||
_logger.Info("Download completed for update package from [{0}]", updatePackage.FileName);
|
_logger.Info("Download completed for update package from [{0}]", updatePackage.FileName);
|
||||||
|
|
||||||
_logger.Info("Extracting Update package");
|
_logger.Info("Extracting Update package");
|
||||||
_archiveProvider.ExtractArchive(packageDestination, _environmentProvider.GetUpdateSandboxFolder());
|
_archiveProvider.ExtractArchive(packageDestination, updateSandboxFolder);
|
||||||
_logger.Info("Update package extracted successfully");
|
_logger.Info("Update package extracted successfully");
|
||||||
|
|
||||||
_logger.Info("Preparing client");
|
_logger.Info("Preparing client");
|
||||||
_diskProvider.MoveDirectory(_environmentProvider.GetUpdateClientFolder(), _environmentProvider.GetUpdateSandboxFolder());
|
_diskProvider.MoveDirectory(_environmentProvider.GetUpdateClientFolder(),
|
||||||
|
updateSandboxFolder);
|
||||||
|
|
||||||
|
|
||||||
_logger.Info("Starting update client");
|
_logger.Info("Starting update client");
|
||||||
@ -86,27 +90,42 @@ public Dictionary<DateTime, string> GetUpdateLogFiles()
|
|||||||
if (_diskProvider.FolderExists(_environmentProvider.GetUpdateLogFolder()))
|
if (_diskProvider.FolderExists(_environmentProvider.GetUpdateLogFolder()))
|
||||||
{
|
{
|
||||||
var provider = CultureInfo.InvariantCulture;
|
var provider = CultureInfo.InvariantCulture;
|
||||||
var files = _diskProvider.GetFiles(_environmentProvider.GetUpdateLogFolder(), SearchOption.TopDirectoryOnly).ToList();
|
var files =
|
||||||
|
_diskProvider.GetFiles(_environmentProvider.GetUpdateLogFolder(), SearchOption.TopDirectoryOnly)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
foreach (var file in files.Select(c => new FileInfo(c)).OrderByDescending(c => c.Name))
|
foreach (var file in files.Select(c => new FileInfo(c)).OrderByDescending(c => c.Name))
|
||||||
{
|
{
|
||||||
list.Add(DateTime.ParseExact(file.Name.Replace(file.Extension, string.Empty), "yyyy.MM.dd-H-mm", provider), file.FullName);
|
list.Add(
|
||||||
|
DateTime.ParseExact(file.Name.Replace(file.Extension, string.Empty), "yyyy.MM.dd-H-mm", provider),
|
||||||
|
file.FullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute(ApplicationUpdateCommand message)
|
public UpdatePackage AvailableUpdate()
|
||||||
{
|
{
|
||||||
var latestAvailable = _updatePackageProvider.GetLatestUpdate();
|
var latestAvailable = _updatePackageProvider.GetLatestUpdate();
|
||||||
|
|
||||||
if (latestAvailable == null || latestAvailable.Version <= _environmentProvider.Version)
|
if (latestAvailable == null || latestAvailable.Version <= _environmentProvider.Version)
|
||||||
{
|
{
|
||||||
_logger.Debug("No update available.");
|
_logger.Debug("No update available.");
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return latestAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Execute(ApplicationUpdateCommand message)
|
||||||
|
{
|
||||||
|
var latestAvailable = AvailableUpdate();
|
||||||
|
|
||||||
|
if (latestAvailable != null)
|
||||||
|
{
|
||||||
InstallUpdate(latestAvailable);
|
InstallUpdate(latestAvailable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<extensions>
|
||||||
|
<add assembly="NzbDrone.Common"/>
|
||||||
|
</extensions>
|
||||||
<targets>
|
<targets>
|
||||||
<target xsi:type="ColoredConsole" name="consoleLogger" layout="[${level}] ${logger}: ${message} ${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}"/>
|
<target xsi:type="ColoredConsole" name="consoleLogger" layout="[${level}] ${logger}: ${message} ${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}"/>
|
||||||
<target xsi:type="File" name="fileLogger" fileName="${date:format=yyyy.MM.dd-H-mm}.txt" autoFlush="true" keepFileOpen="false"
|
<target xsi:type="File" name="fileLogger" fileName="${updateLog}" autoFlush="true" keepFileOpen="false"
|
||||||
concurrentWrites="false" concurrentWriteAttemptDelay="50" concurrentWriteAttempts ="10"
|
concurrentWrites="false" concurrentWriteAttemptDelay="50" concurrentWriteAttempts ="10"
|
||||||
layout="${date:format=yy-M-d HH\:mm\:ss.f}|${logger}}|${level}|${message}|${exception:format=ToString}"/>
|
layout="${date:format=yy-M-d HH\:mm\:ss.f}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}"/>
|
||||||
</targets>
|
</targets>
|
||||||
<rules>
|
<rules>
|
||||||
<logger name="*" minlevel="Debug" writeTo="consoleLogger"/>
|
<logger name="*" minlevel="Debug" writeTo="consoleLogger"/>
|
||||||
|
@ -37,28 +37,10 @@ public static void Main(string[] args)
|
|||||||
logger.FatalException("An error has occurred while applying update package.", e);
|
logger.FatalException("An error has occurred while applying update package.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
TransferUpdateLogs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void TransferUpdateLogs()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var environmentProvider = _container.Resolve<IEnvironmentProvider>();
|
|
||||||
var diskProvider = _container.Resolve<IDiskProvider>();
|
|
||||||
logger.Info("Copying log files to application directory.");
|
|
||||||
diskProvider.CopyDirectory(environmentProvider.GetSandboxLogFolder(), environmentProvider.GetUpdateLogFolder());
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
logger.FatalException("Can't copy upgrade log files to target folder", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void Start(string[] args)
|
public void Start(string[] args)
|
||||||
{
|
{
|
||||||
VerfityArguments(args);
|
|
||||||
int processId = ParseProcessId(args);
|
int processId = ParseProcessId(args);
|
||||||
|
|
||||||
var exeFileInfo = new FileInfo(_processProvider.GetProcessById(processId).StartPath);
|
var exeFileInfo = new FileInfo(_processProvider.GetProcessById(processId).StartPath);
|
||||||
@ -79,13 +61,5 @@ private int ParseProcessId(string[] args)
|
|||||||
logger.Debug("NzbDrone processId:{0}", id);
|
logger.Debug("NzbDrone processId:{0}", id);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void VerfityArguments(string[] args)
|
|
||||||
{
|
|
||||||
if (args == null || args.Length != 2)
|
|
||||||
throw new ArgumentException("Wrong number of parameters were passed in.");
|
|
||||||
|
|
||||||
logger.Debug("Arguments verified. [{0}] , [{1}]", args[0], args[1]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ namespace NzbDrone.Update
|
|||||||
{
|
{
|
||||||
public class UpdateContainerBuilder : ContainerBuilderBase
|
public class UpdateContainerBuilder : ContainerBuilderBase
|
||||||
{
|
{
|
||||||
public UpdateContainerBuilder()
|
private UpdateContainerBuilder()
|
||||||
: base("NzbDrone.Update", "NzbDrone.Common")
|
: base("NzbDrone.Update", "NzbDrone.Common")
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using NzbDrone.Core.Update;
|
||||||
|
using NzbDrone.Core.Update.Commands;
|
||||||
|
|
||||||
namespace NzbDrone
|
namespace NzbDrone
|
||||||
{
|
{
|
||||||
@ -42,6 +44,14 @@ public static void Main(string[] args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
var container = MainAppContainerBuilder.BuildContainer();
|
var container = MainAppContainerBuilder.BuildContainer();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
container.Resolve<IUpdateService>().Execute(new ApplicationUpdateCommand());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
logger.ErrorException("Application update failed.", e);
|
||||||
|
}
|
||||||
|
|
||||||
container.Resolve<Router>().Route(args);
|
container.Resolve<Router>().Route(args);
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,8 @@
|
|||||||
autoReload="true"
|
autoReload="true"
|
||||||
internalLogLevel="Info"
|
internalLogLevel="Info"
|
||||||
throwExceptions="true"
|
throwExceptions="true"
|
||||||
internalLogToConsole="false"
|
internalLogToConsole="true"
|
||||||
internalLogToConsoleError="true"
|
internalLogToConsoleError="true">
|
||||||
internalLogFile="nlog.txt">
|
|
||||||
<extensions>
|
<extensions>
|
||||||
<add assembly="NzbDrone.Core"/>
|
<add assembly="NzbDrone.Core"/>
|
||||||
<add assembly="NzbDrone.Common"/>
|
<add assembly="NzbDrone.Common"/>
|
||||||
@ -19,14 +18,14 @@
|
|||||||
<layout>${exception:format=ToString}</layout>
|
<layout>${exception:format=ToString}</layout>
|
||||||
</parameter>
|
</parameter>
|
||||||
</target>
|
</target>
|
||||||
<target xsi:type="File" name="rollingFileLogger" fileName="nzbdrone.log.txt" autoFlush="true" keepFileOpen="false"
|
<target xsi:type="File" name="rollingFileLogger" fileName="${appLog}" autoFlush="true" keepFileOpen="false"
|
||||||
concurrentWrites="false" concurrentWriteAttemptDelay="50" concurrentWriteAttempts ="10"
|
concurrentWrites="false" concurrentWriteAttemptDelay="50" concurrentWriteAttempts ="10"
|
||||||
archiveAboveSize="1024000" maxArchiveFiles="5" enableFileDelete="true" archiveNumbering ="Rolling"
|
archiveAboveSize="1024000" maxArchiveFiles="5" enableFileDelete="true" archiveNumbering ="Rolling"
|
||||||
layout="${date:format=yy-M-d HH\:mm\:ss.f}|${logger}}|${level}|${message}|${exception:format=ToString}"/>
|
layout="${date:format=yy-M-d HH\:mm\:ss.f}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}"/>
|
||||||
</targets>
|
</targets>
|
||||||
<rules>
|
<rules>
|
||||||
<logger name="*" minlevel="Trace" writeTo="consoleLogger"/>
|
<logger name="*" minlevel="Trace" writeTo="consoleLogger"/>
|
||||||
<logger name="*" minlevel="Off" writeTo="udpTarget"/>
|
<logger name="*" minlevel="Off" writeTo="udpTarget"/>
|
||||||
<logger name="*" minlevel="Warn" writeTo="rollingFileLogger"/>
|
<logger name="*" minlevel="Debug" writeTo="rollingFileLogger"/>
|
||||||
</rules>
|
</rules>
|
||||||
</nlog>
|
</nlog>
|
@ -77,12 +77,6 @@ Function Nunit()
|
|||||||
Function RunGrunt()
|
Function RunGrunt()
|
||||||
{
|
{
|
||||||
$gruntPath = [environment]::getfolderpath("applicationdata") + '\npm\node_modules\grunt-cli\bin\grunt'
|
$gruntPath = [environment]::getfolderpath("applicationdata") + '\npm\node_modules\grunt-cli\bin\grunt'
|
||||||
|
|
||||||
if(!(Test-Path $gruntPath))
|
|
||||||
{
|
|
||||||
Invoke-Expression 'npm install grunt-cli -g'
|
|
||||||
}
|
|
||||||
|
|
||||||
Invoke-Expression 'npm install'
|
Invoke-Expression 'npm install'
|
||||||
|
|
||||||
Invoke-Expression ('node ' + $gruntPath + ' package')
|
Invoke-Expression ('node ' + $gruntPath + ' package')
|
||||||
|
Loading…
Reference in New Issue
Block a user