Merge branch 'develop'
This commit is contained in:
commit
c5e35da659
|
@ -0,0 +1,68 @@
|
|||
# NzbDrone Individual Contributor License Agreement #
|
||||
|
||||
Thank you for your interest in contributing to NzbDrone ("We" or "Us").
|
||||
This contributor agreement ("Agreement") documents the rights granted by contributors to Us. To make this document effective, please complete the form below. This is a legally binding document, so please read it carefully before agreeing to it. The Agreement may cover more than one software project managed by Us.
|
||||
|
||||
## 1. Definitions ##
|
||||
|
||||
"You" means the individual who Submits a Contribution to Us.
|
||||
"Contribution" means any work of authorship that is Submitted by You to Us in which You own or assert ownership of the Copyright. If You do not own the Copyright in the entire work of authorship, please follow the instructions in .
|
||||
"Copyright" means all rights protecting works of authorship owned or controlled by You, including copyright, moral and neighboring rights, as appropriate, for the full term of their existence including any extensions by You.
|
||||
"Material" means the work of authorship which is made available by Us to third parties. When this Agreement covers more than one software project, the Material means the work of authorship to which the Contribution was Submitted. After You Submit the Contribution, it may be included in the Material.
|
||||
"Submit" means any form of electronic, verbal, or written communication sent to Us or our representatives, including but not limited to electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, Us for the purpose of discussing and improving the Material, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution."
|
||||
"Submission Date" means the date on which You Submit a Contribution to Us.
|
||||
"Effective Date" means the date You execute this Agreement or the date You first Submit a Contribution to Us, whichever is earlier.
|
||||
|
||||
## 2. Grant of Rights ##
|
||||
|
||||
### 2.1 Copyright License ###
|
||||
(a) You retain ownership of the Copyright in Your Contribution and have the same rights to use or license the Contribution which You would have had without entering into the Agreement.
|
||||
(b) To the maximum extent permitted by the relevant law, You grant to Us a perpetual, worldwide, non-exclusive, transferable, royalty-free, irrevocable license under the Copyright covering the Contribution, with the right to sublicense such rights through multiple tiers of sublicensees, to reproduce, modify, display, perform and distribute the Contribution as part of the Material; provided that this license is conditioned upon compliance with Section 2.3.
|
||||
|
||||
### 2.2 Patent License ###
|
||||
For patent claims including, without limitation, method, process, and apparatus claims which You own, control or have the right to grant, now or in the future, You grant to Us a perpetual, worldwide, non-exclusive, transferable, royalty-free, irrevocable patent license, with the right to sublicense these rights to multiple tiers of sublicensees, to make, have made, use, sell, offer for sale, import and otherwise transfer the Contribution and the Contribution in combination with the Material (and portions of such combination). This license is granted only to the extent that the exercise of the licensed rights infringes such patent claims; and provided that this license is conditioned upon compliance with Section 2.3.
|
||||
|
||||
### 2.3 Outbound License ###
|
||||
As a condition on the grant of rights in Sections 2.1 and 2.2, We agree to license the Contribution only under the terms of the license or licenses which We are using on the Submission Date for the Material (including any rights to adopt any future version of a license if permitted).
|
||||
|
||||
### 2.4 Moral Rights. ###
|
||||
If moral rights apply to the Contribution, to the maximum extent permitted by law, You waive and agree not to assert such moral rights against Us or our successors in interest, or any of our licensees, either direct or indirect.
|
||||
|
||||
### 2.5 Our Rights. ###
|
||||
You acknowledge that We are not obligated to use Your Contribution as part of the Material and may decide to include any Contribution We consider appropriate.
|
||||
|
||||
### 2.6 Reservation of Rights. ###
|
||||
Any rights not expressly licensed under this section are expressly reserved by You.
|
||||
|
||||
## 3. Agreement ##
|
||||
|
||||
You confirm that:
|
||||
(a) You have the legal authority to enter into this Agreement.
|
||||
(b) You own the Copyright and patent claims covering the Contribution which are required to grant the rights under Section 2.
|
||||
(c) The grant of rights under Section 2 does not violate any grant of rights which You have made to third parties, including Your employer. If You are an employee, You have had Your employer approve this Agreement or sign the Entity version of this document. If You are less than eighteen years old, please have Your parents or guardian sign the Agreement.
|
||||
(d) You have followed the instructions in , if You do not own the Copyright in the entire work of authorship Submitted.
|
||||
|
||||
## 4. Disclaimer ##
|
||||
|
||||
EXCEPT FOR THE EXPRESS WARRANTIES IN SECTION 3, THE CONTRIBUTION IS PROVIDED "AS IS". MORE PARTICULARLY, ALL EXPRESS OR IMPLIED WARRANTIES INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY DISCLAIMED BY YOU TO US. TO THE EXTENT THAT ANY SUCH WARRANTIES CANNOT BE DISCLAIMED, SUCH WARRANTY IS LIMITED IN DURATION TO THE MINIMUM PERIOD PERMITTED BY LAW.
|
||||
|
||||
## 5. Consequential Damage Waiver ##
|
||||
|
||||
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT WILL YOU BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF ANTICIPATED SAVINGS, LOSS OF DATA, INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL AND EXEMPLARY DAMAGES ARISING OUT OF THIS AGREEMENT REGARDLESS OF THE LEGAL OR EQUITABLE THEORY (CONTRACT, TORT OR OTHERWISE) UPON WHICH THE CLAIM IS BASED.
|
||||
|
||||
## 6. Miscellaneous ##
|
||||
|
||||
### 6.1 ###
|
||||
This Agreement will be governed by and construed in accordance with the laws of excluding its conflicts of law provisions. Under certain circumstances, the governing law in this section might be superseded by the United Nations Convention on Contracts for the International Sale of Goods ("UN Convention") and the parties intend to avoid the application of the UN Convention to this Agreement and, thus, exclude the application of the UN Convention in its entirety to this Agreement.
|
||||
|
||||
### 6.2 ###
|
||||
This Agreement sets out the entire agreement between You and Us for Your Contributions to Us and overrides all other agreements or understandings.
|
||||
|
||||
### 6.3 ###
|
||||
If You or We assign the rights or obligations received through this Agreement to a third party, as a condition of the assignment, that third party must agree in writing to abide by all the rights and obligations in the Agreement.
|
||||
|
||||
### 6.4 ###
|
||||
The failure of either party to require performance by the other party of any provision of this Agreement in one situation shall not affect the right of a party to require such performance at any time in the future. A waiver of performance under a provision in one situation shall not be considered a waiver of the performance of the provision in the future or a waiver of the provision in its entirety.
|
||||
|
||||
### 6.5 ###
|
||||
If any provision of this Agreement is found void and unenforceable, such provision will be replaced to the extent possible with a provision that comes closest to the meaning of the original provision and which is enforceable. The terms and conditions set forth in this Agreement shall apply notwithstanding any failure of essential purpose of this Agreement or any limited remedy to the maximum extent possible under law.
|
|
@ -0,0 +1,39 @@
|
|||
# How to Contribute #
|
||||
|
||||
We're always looking for people to help make NzbDrone even better, there are a number of ways to contribute. To get started, <a href="http://www.clahub.com/agreements/NzbDrone/NzbDrone">sign the Contributor License Agreement</a>.
|
||||
|
||||
## Documentation ##
|
||||
Setup guides, FAQ, the more information we have on the wiki the better.
|
||||
|
||||
## Development ##
|
||||
|
||||
### Tools required ###
|
||||
- Visual Studio 2012
|
||||
- HTML/Javascript editor of choice (Sublime Text/Webstorm/etc)
|
||||
- npm (node package manager)
|
||||
- git
|
||||
|
||||
### Getting started ###
|
||||
|
||||
1. Fork NzbDrone
|
||||
2. Clone (develop branch)
|
||||
3. Run `npm install`
|
||||
4. Run `grunt` - Used to compile the UI components and copy them (leave this window open)
|
||||
5. Compile in Visual Studio
|
||||
|
||||
### Contributing Code ###
|
||||
- If you're adding a new, already requested feature, please move it to In Progress on [Trello](http://trello.nzbdrone.com "Trello") so work is not duplicated.
|
||||
- Rebase from NzbDrone's develop branch, don't merge
|
||||
- Make meaningful commits, or squash them
|
||||
- Feel free to make a pull request before work is complete, this will let us see where its at and make comments/suggest improvements
|
||||
- Reach out to us on the forums or on IRC if you have any questions
|
||||
- Add tests (unit/integration)
|
||||
- Commit with *nix line endings for consistency (We checkout Windows and commit *nix)
|
||||
- Try to stick to one feature per request to keep things clean and easy to understand
|
||||
- Use 4 spaces instead of tabs, this is the default for VS 2012 and WebStorm (to my knowledge)
|
||||
|
||||
### Pull Requesting ###
|
||||
- You're probably going to get some comments or questions from us, they will be to ensure consistency and maintainability
|
||||
- We'll try to respond to pull requests as soon as possible, if its been a day or two, please reach out to us, we may have missed it
|
||||
|
||||
If you have any questions about any of this, please let us know.
|
49
build.ps1
49
build.ps1
|
@ -4,6 +4,7 @@ $outputFolderMono = '.\_output_mono'
|
|||
$testPackageFolder = '.\_tests\'
|
||||
$testSearchPattern = '*.Test\bin\x86\Release'
|
||||
$sourceFolder = '.\src'
|
||||
$updateFolder = $outputFolder + '\NzbDrone.Update'
|
||||
|
||||
Function Build()
|
||||
{
|
||||
|
@ -27,6 +28,9 @@ Function Build()
|
|||
|
||||
AddJsonNet
|
||||
|
||||
Write-Host "Removing Mono.Posix.dll"
|
||||
Remove-Item "$outputFolder\Mono.Posix.dll"
|
||||
|
||||
Write-Host "##teamcity[progressFinish 'Build']"
|
||||
}
|
||||
|
||||
|
@ -35,21 +39,18 @@ Function CleanFolder($path)
|
|||
Write-Host Removing XMLDoc files
|
||||
get-childitem $path -File -Filter *.xml -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
get-childitem $path -File -Filter *.transform -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
get-childitem $path -File -Filter *.transform -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
get-childitem $path -File -Filter *.dll.config -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
get-childitem $path -File -Filter *.dll.config -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
Write-Host Removing FluentValidation.Resources files
|
||||
get-childitem $path -File -Filter FluentValidation.resources.dll -recurse | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
get-childitem $path -File -Filter app.config -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
get-childitem $path -File -Filter app.config -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
Write-Host Removing .less files
|
||||
get-childitem $path -File -Filter *.less -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
|
||||
Write-Host Removing NuGet
|
||||
Remove-Item -Recurse -Force "$path\NuGet"
|
||||
|
||||
|
@ -84,20 +85,23 @@ Function PackageMono()
|
|||
get-childitem $outputFolderMono -File -Filter *.pdb -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
Write-Host Removing Service helpers
|
||||
get-childitem $outputFolderMono -File -Filter ServiceUninstall.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
get-childitem $outputFolderMono -File -Filter ServiceInstall.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
get-childitem $outputFolderMono -File -Filter ServiceUninstall.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
get-childitem $outputFolderMono -File -Filter ServiceInstall.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
Write-Host Removing native windows binaries Sqlite, MediaInfo
|
||||
get-childitem $outputFolderMono -File -Filter sqlite3.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
get-childitem $outputFolderMono -File -Filter MediaInfo.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
get-childitem $outputFolderMono -File -Filter sqlite3.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
get-childitem $outputFolderMono -File -Filter MediaInfo.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
Write-Host "Adding MediaInfoDotNet.dll.config (for dllmap)"
|
||||
Copy-Item "$sourceFolder\MediaInfoDotNet.dll.config" $outputFolderMono
|
||||
|
||||
Write-Host Renaming NzbDrone.Console.exe to NzbDrone.exe
|
||||
Get-ChildItem $outputFolderMono -File -Filter "NzbDrone.exe*" -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
Get-ChildItem $outputFolderMono -File -Filter "NzbDrone.exe*" -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
Get-ChildItem $outputFolderMono -File -Filter "NzbDrone.Console.exe*" -Recurse | foreach ($_) {
|
||||
Write-Host Removing NzbDrone.Windows
|
||||
get-childitem $outputFolderMono -File -Filter NzbDrone.Windows.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
Get-ChildItem $outputFolderMono -File -Filter "NzbDrone.Console.exe*" -Recurse | foreach ($_) {
|
||||
$newName = $_.fullname -Replace ".Console",""
|
||||
|
||||
Rename-Item $_.fullname $newName
|
||||
|
@ -108,12 +112,11 @@ Function PackageMono()
|
|||
Write-Host "##teamcity[progressFinish 'Creating Mono Package']"
|
||||
}
|
||||
|
||||
|
||||
Function AddJsonNet()
|
||||
{
|
||||
get-childitem $outputFolder -File -Filter Newtonsoft.Json.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
Copy-Item .\src\packages\Newtonsoft.Json.5.*\lib\net35\*.dll -Destination $outputFolder
|
||||
Copy-Item .\src\packages\Newtonsoft.Json.5.*\lib\net35\*.dll -Destination $outputFolder\NzbDrone.Update
|
||||
get-childitem $outputFolder -File -Filter Newtonsoft.Json.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
Copy-Item .\src\packages\Newtonsoft.Json.5.*\lib\net35\*.dll -Destination $outputFolder
|
||||
Copy-Item .\src\packages\Newtonsoft.Json.5.*\lib\net35\*.dll -Destination $outputFolder\NzbDrone.Update
|
||||
}
|
||||
|
||||
Function PackageTests()
|
||||
|
@ -127,8 +130,7 @@ Function PackageTests()
|
|||
Remove-Item -Recurse -Force $testPackageFolder -ErrorAction Continue
|
||||
}
|
||||
|
||||
|
||||
Get-ChildItem -Recurse -Directory | Where-Object {$_.FullName -like $testSearchPattern} | foreach($_){
|
||||
Get-ChildItem -Recurse -Directory | Where-Object {$_.FullName -like $testSearchPattern} | foreach($_){
|
||||
Copy-Item -Recurse ($_.FullName + "\*") $testPackageFolder -ErrorAction Ignore
|
||||
}
|
||||
|
||||
|
@ -149,7 +151,6 @@ Function PackageTests()
|
|||
Write-Host "##teamcity[progressFinish 'Creating Test Package']"
|
||||
}
|
||||
|
||||
|
||||
Function RunGrunt()
|
||||
{
|
||||
Write-Host "##teamcity[progressStart 'Running Grunt']"
|
||||
|
@ -174,7 +175,17 @@ Function CheckExitCode()
|
|||
}
|
||||
}
|
||||
|
||||
Function CleanupWindowsPackage()
|
||||
{
|
||||
Write-Host Removing NzbDrone.Mono
|
||||
get-childitem $outputFolder -File -Filter NzbDrone.Mono.* -Recurse | foreach ($_) {remove-item $_.fullname}
|
||||
|
||||
Write-Host Adding NzbDrone.Windows to UpdatePackage
|
||||
Copy-Item $outputFolder\* $updateFolder -Filter NzbDrone.Windows.*
|
||||
}
|
||||
|
||||
Build
|
||||
RunGrunt
|
||||
PackageMono
|
||||
PackageTests
|
||||
CleanupWindowsPackage
|
||||
|
|
Binary file not shown.
|
@ -6,6 +6,7 @@ using Moq;
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Api.Directories;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Api.Test
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using NzbDrone.Core.Blacklisting;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
namespace NzbDrone.Api.Blacklist
|
||||
{
|
||||
public class BlacklistModule : NzbDroneRestModule<BlacklistResource>
|
||||
{
|
||||
private readonly IBlacklistService _blacklistService;
|
||||
|
||||
public BlacklistModule(IBlacklistService blacklistService)
|
||||
{
|
||||
_blacklistService = blacklistService;
|
||||
GetResourcePaged = GetBlacklist;
|
||||
DeleteResource = Delete;
|
||||
}
|
||||
|
||||
private PagingResource<BlacklistResource> GetBlacklist(PagingResource<BlacklistResource> pagingResource)
|
||||
{
|
||||
var pagingSpec = new PagingSpec<Core.Blacklisting.Blacklist>
|
||||
{
|
||||
Page = pagingResource.Page,
|
||||
PageSize = pagingResource.PageSize,
|
||||
SortKey = pagingResource.SortKey,
|
||||
SortDirection = pagingResource.SortDirection
|
||||
};
|
||||
|
||||
//This is a hack to deal with backgrid setting the sortKey to the column name instead of sortValue
|
||||
if (pagingSpec.SortKey.Equals("series", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
pagingSpec.SortKey = "series.title";
|
||||
}
|
||||
|
||||
return ApplyToPage(_blacklistService.Paged, pagingSpec);
|
||||
}
|
||||
|
||||
private void Delete(int id)
|
||||
{
|
||||
_blacklistService.Delete(id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Api.Blacklist
|
||||
{
|
||||
public class BlacklistResource : RestResource
|
||||
{
|
||||
public int SeriesId { get; set; }
|
||||
public List<int> EpisodeIds { get; set; }
|
||||
public string SourceTitle { get; set; }
|
||||
public QualityModel Quality { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
|
||||
namespace NzbDrone.Api.Directories
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Text.RegularExpressions;
|
|||
using Nancy;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.IO;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
namespace NzbDrone.Api.Frontend.Mappers
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.IO;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
namespace NzbDrone.Api.Frontend.Mappers
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.IO;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
namespace NzbDrone.Api.Frontend.Mappers
|
||||
|
|
|
@ -3,6 +3,7 @@ using NLog;
|
|||
using Nancy;
|
||||
using Nancy.Responses;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
namespace NzbDrone.Api.Frontend.Mappers
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
namespace NzbDrone.Api.Logs
|
||||
|
|
|
@ -23,6 +23,31 @@ namespace NzbDrone.Api.Logs
|
|||
pageSpec.SortKey = "id";
|
||||
}
|
||||
|
||||
if (pagingResource.FilterKey == "level")
|
||||
{
|
||||
switch (pagingResource.FilterValue)
|
||||
{
|
||||
case "Fatal":
|
||||
pageSpec.FilterExpression = h => h.Level == "Fatal";
|
||||
break;
|
||||
case "Error":
|
||||
pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error";
|
||||
break;
|
||||
case "Warn":
|
||||
pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn";
|
||||
break;
|
||||
case "Info":
|
||||
pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info";
|
||||
break;
|
||||
case "Debug":
|
||||
pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info" || h.Level == "Debug";
|
||||
break;
|
||||
case "Trace":
|
||||
pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info" || h.Level == "Debug" || h.Level == "Trace";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ApplyToPage(_logService.Paged, pageSpec);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,8 @@
|
|||
<Compile Include="Authentication\EnableStatelessAuthInNancy.cs" />
|
||||
<Compile Include="Authentication\EnableBasicAuthInNancy.cs" />
|
||||
<Compile Include="Authentication\NzbDroneUser.cs" />
|
||||
<Compile Include="Blacklist\BlacklistModule.cs" />
|
||||
<Compile Include="Blacklist\BlacklistResource.cs" />
|
||||
<Compile Include="Calendar\CalendarModule.cs" />
|
||||
<Compile Include="ClientSchema\SchemaDeserializer.cs" />
|
||||
<Compile Include="ClientSchema\FieldDefinitionAttribute.cs" />
|
||||
|
|
|
@ -9,6 +9,8 @@ namespace NzbDrone.Api
|
|||
public int PageSize { get; set; }
|
||||
public string SortKey { get; set; }
|
||||
public SortDirection SortDirection { get; set; }
|
||||
public string FilterKey { get; set; }
|
||||
public string FilterValue { get; set; }
|
||||
public int TotalRecords { get; set; }
|
||||
public List<TModel> Records { get; set; }
|
||||
}
|
||||
|
|
|
@ -241,6 +241,16 @@ namespace NzbDrone.Api.REST
|
|||
}
|
||||
}
|
||||
|
||||
if (Request.Query.FilterKey != null)
|
||||
{
|
||||
pagingResource.FilterKey = Request.Query.FilterKey.ToString();
|
||||
|
||||
if (Request.Query.FilterValue != null)
|
||||
{
|
||||
pagingResource.FilterValue = Request.Query.FilterValue.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
return pagingResource;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace NzbDrone.App.Test
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_resolve_downlodclients()
|
||||
public void should_be_able_to_resolve_downloadclients()
|
||||
{
|
||||
MainAppContainerBuilder.BuildContainer(args).Resolve<IEnumerable<IDownloadClient>>().Should().NotBeEmpty();
|
||||
}
|
||||
|
|
|
@ -97,6 +97,10 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>xcopy /s /y "$(SolutionDir)\..\_output\NzbDrone.Mono.*" "$(TargetDir)"
|
||||
xcopy /s /y "$(SolutionDir)\..\_output\NzbDrone.Windows.*" "$(TargetDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
@ -3,12 +3,12 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Common.Test.DiskProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class DiskProviderFixture : TestBase<DiskProvider>
|
||||
public class DiskProviderFixtureBase<TSubject> : TestBase<TSubject> where TSubject : class, IDiskProvider
|
||||
{
|
||||
DirectoryInfo _binFolder;
|
||||
DirectoryInfo _binFolderCopy;
|
||||
|
@ -91,7 +91,6 @@ namespace NzbDrone.Common.Test.DiskProviderTests
|
|||
VerifyCopy();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void CopyFolder_should_overwrite_existing_folder()
|
||||
{
|
||||
|
@ -126,7 +125,6 @@ namespace NzbDrone.Common.Test.DiskProviderTests
|
|||
VerifyMove();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void move_read_only_file()
|
||||
{
|
||||
|
@ -142,9 +140,6 @@ namespace NzbDrone.Common.Test.DiskProviderTests
|
|||
Subject.MoveFile(source, destination);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void empty_folder_should_return_folder_modified_date()
|
||||
{
|
||||
|
@ -161,12 +156,11 @@ namespace NzbDrone.Common.Test.DiskProviderTests
|
|||
Directory.CreateDirectory(testDir);
|
||||
|
||||
TestLogger.Info("Path is: {0}", testFile);
|
||||
|
||||
|
||||
Subject.WriteAllText(testFile, "Test");
|
||||
|
||||
Subject.GetLastFolderWrite(SandboxFolder).Should().BeOnOrAfter(DateTime.UtcNow.AddMinutes(-1));
|
||||
Subject.GetLastFolderWrite(SandboxFolder).Should().BeBefore(DateTime.UtcNow);
|
||||
Subject.GetLastFolderWrite(SandboxFolder).Should().BeBefore(DateTime.UtcNow.AddMinutes(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -189,7 +183,6 @@ namespace NzbDrone.Common.Test.DiskProviderTests
|
|||
Subject.IsFileLocked(testFile).Should().BeFalse();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_return_true_for_unlocked_file()
|
||||
{
|
||||
|
@ -202,7 +195,6 @@ namespace NzbDrone.Common.Test.DiskProviderTests
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_set_permission_from_parrent()
|
||||
{
|
||||
|
@ -212,7 +204,6 @@ namespace NzbDrone.Common.Test.DiskProviderTests
|
|||
Subject.InheritFolderPermissions(testFile);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
[Explicit]
|
||||
public void check_last_write()
|
|
@ -1,43 +0,0 @@
|
|||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Common.Test.DiskProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class FreeSpaceFixture : TestBase<DiskProvider>
|
||||
{
|
||||
[Test]
|
||||
public void should_get_free_space_for_folder()
|
||||
{
|
||||
var path = @"C:\".AsOsAgnostic();
|
||||
|
||||
Subject.GetAvailableSpace(path).Should().NotBe(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_free_space_for_folder_that_doesnt_exist()
|
||||
{
|
||||
var path = @"C:\".AsOsAgnostic();
|
||||
|
||||
Subject.GetAvailableSpace(Path.Combine(path, "invalidFolder")).Should().NotBe(0);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_get_free_space_for_drive_that_doesnt_exist()
|
||||
{
|
||||
WindowsOnly();
|
||||
|
||||
Assert.Throws<DirectoryNotFoundException>(() => Subject.GetAvailableSpace("J:\\").Should().NotBe(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_check_space_on_ramdrive()
|
||||
{
|
||||
LinuxOnly();
|
||||
Subject.GetAvailableSpace("/run/").Should().NotBe(0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,15 +2,44 @@
|
|||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests
|
||||
namespace NzbDrone.Common.Test.DiskProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class FreeDiskSpaceFixture : CoreTest<DiskProvider>
|
||||
public abstract class FreeSpaceFixtureBase<TSubject> : TestBase<TSubject> where TSubject : class, IDiskProvider
|
||||
{
|
||||
[Test]
|
||||
public void should_get_free_space_for_folder()
|
||||
{
|
||||
var path = @"C:\".AsOsAgnostic();
|
||||
|
||||
Subject.GetAvailableSpace(path).Should().NotBe(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_free_space_for_folder_that_doesnt_exist()
|
||||
{
|
||||
var path = @"C:\".AsOsAgnostic();
|
||||
|
||||
Subject.GetAvailableSpace(Path.Combine(path, "invalidFolder")).Should().NotBe(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_free_space_for_drive_that_doesnt_exist()
|
||||
{
|
||||
WindowsOnly();
|
||||
|
||||
Assert.Throws<DirectoryNotFoundException>(() => Subject.GetAvailableSpace("J:\\").Should().NotBe(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_check_space_on_ramdrive()
|
||||
{
|
||||
LinuxOnly();
|
||||
Subject.GetAvailableSpace("/run/").Should().NotBe(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_free_disk_space()
|
||||
{
|
|
@ -1,11 +1,11 @@
|
|||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Common.Test.DiskProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class IsParentFixture : TestBase<DiskProvider>
|
||||
public class IsParentFixtureBase<TSubject> : TestBase<TSubject> where TSubject : class, IDiskProvider
|
||||
{
|
||||
private string _parent = @"C:\Test".AsOsAgnostic();
|
||||
|
|
@ -62,14 +62,14 @@
|
|||
<Compile Include="CacheTests\CachedManagerFixture.cs" />
|
||||
<Compile Include="CacheTests\CachedFixture.cs" />
|
||||
<Compile Include="ConfigFileProviderTest.cs" />
|
||||
<Compile Include="DiskProviderTests\FreeSpaceFixture.cs" />
|
||||
<Compile Include="DiskProviderTests\IsParentFixture.cs" />
|
||||
<Compile Include="DiskProviderTests\FreeSpaceFixtureBase.cs" />
|
||||
<Compile Include="DiskProviderTests\IsParentFixtureBase.cs" />
|
||||
<Compile Include="EnsureTest\PathExtensionFixture.cs" />
|
||||
<Compile Include="EnvironmentTests\StartupArgumentsFixture.cs" />
|
||||
<Compile Include="EnvironmentTests\EnvironmentProviderTest.cs" />
|
||||
<Compile Include="ReflectionExtensions.cs" />
|
||||
<Compile Include="PathExtensionFixture.cs" />
|
||||
<Compile Include="DiskProviderTests\DiskProviderFixture.cs" />
|
||||
<Compile Include="DiskProviderTests\DiskProviderFixtureBase.cs" />
|
||||
<Compile Include="EnvironmentProviderTest.cs" />
|
||||
<Compile Include="ProcessProviderTests.cs" />
|
||||
<Compile Include="ReflectionTests\ReflectionExtensionFixture.cs" />
|
||||
|
|
|
@ -67,6 +67,5 @@ namespace NzbDrone.Common.Composition
|
|||
Container.RegisterAllAsSingleton(contractType, implementations);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,54 +1,15 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Principal;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnsureThat;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
namespace NzbDrone.Common.Disk
|
||||
{
|
||||
public interface IDiskProvider
|
||||
{
|
||||
DateTime GetLastFolderWrite(string path);
|
||||
DateTime GetLastFileWrite(string path);
|
||||
void EnsureFolder(string path);
|
||||
bool FolderExists(string path);
|
||||
bool FileExists(string path);
|
||||
bool FileExists(string path, bool caseSensitive);
|
||||
string[] GetDirectories(string path);
|
||||
string[] GetFiles(string path, SearchOption searchOption);
|
||||
long GetFolderSize(string path);
|
||||
long GetFileSize(string path);
|
||||
void CreateFolder(string path);
|
||||
void CopyFolder(string source, string destination);
|
||||
void MoveFolder(string source, string destination);
|
||||
void DeleteFile(string path);
|
||||
void MoveFile(string source, string destination);
|
||||
void DeleteFolder(string path, bool recursive);
|
||||
void InheritFolderPermissions(string filename);
|
||||
long? GetAvailableSpace(string path);
|
||||
string ReadAllText(string filePath);
|
||||
void WriteAllText(string filename, string contents);
|
||||
void FileSetLastWriteTimeUtc(string path, DateTime dateTime);
|
||||
void FolderSetLastWriteTimeUtc(string path, DateTime dateTime);
|
||||
bool IsFileLocked(string path);
|
||||
string GetPathRoot(string path);
|
||||
string GetParentFolder(string path);
|
||||
void SetPermissions(string filename, WellKnownSidType accountSid, FileSystemRights rights, AccessControlType controlType);
|
||||
bool IsParent(string parentPath, string childPath);
|
||||
void SetFolderWriteTime(string path, DateTime time);
|
||||
FileAttributes GetFileAttributes(string path);
|
||||
void EmptyFolder(string path);
|
||||
string[] GetFixedDrives();
|
||||
long? GetTotalSize(string path);
|
||||
string GetVolumeLabel(string path);
|
||||
}
|
||||
|
||||
public class DiskProvider : IDiskProvider
|
||||
public abstract class DiskProviderBase : IDiskProvider
|
||||
{
|
||||
enum TransferAction
|
||||
{
|
||||
|
@ -56,15 +17,13 @@ namespace NzbDrone.Common
|
|||
Move
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool GetDiskFreeSpaceEx(string lpDirectoryName,
|
||||
out ulong lpFreeBytesAvailable,
|
||||
out ulong lpTotalNumberOfBytes,
|
||||
out ulong lpTotalNumberOfFreeBytes);
|
||||
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
public abstract long? GetAvailableSpace(string path);
|
||||
public abstract void InheritFolderPermissions(string filename);
|
||||
public abstract void SetPermissions(string path, string mask, string user, string group);
|
||||
public abstract long? GetTotalSize(string path);
|
||||
|
||||
public DateTime GetLastFolderWrite(string path)
|
||||
{
|
||||
Ensure.That(path, () => path).IsValidPath();
|
||||
|
@ -272,51 +231,6 @@ namespace NzbDrone.Common
|
|||
Directory.Delete(path, recursive);
|
||||
}
|
||||
|
||||
public void InheritFolderPermissions(string filename)
|
||||
{
|
||||
Ensure.That(filename, () => filename).IsValidPath();
|
||||
|
||||
try
|
||||
{
|
||||
var fs = File.GetAccessControl(filename);
|
||||
fs.SetAccessRuleProtection(false, false);
|
||||
File.SetAccessControl(filename, fs);
|
||||
}
|
||||
catch (NotImplementedException)
|
||||
{
|
||||
if (!OsInfo.IsLinux)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public long? GetAvailableSpace(string path)
|
||||
{
|
||||
Ensure.That(path, () => path).IsValidPath();
|
||||
|
||||
var root = GetPathRoot(path);
|
||||
|
||||
if (!FolderExists(root))
|
||||
throw new DirectoryNotFoundException(root);
|
||||
|
||||
if (OsInfo.IsLinux)
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetDriveInfoLinux(path).AvailableFreeSpace;
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
Logger.ErrorException("Couldn't get free space for " + path, e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return DriveFreeSpaceEx(root);
|
||||
}
|
||||
|
||||
public string ReadAllText(string filePath)
|
||||
{
|
||||
Ensure.That(filePath, () => filePath).IsValidPath();
|
||||
|
@ -394,7 +308,6 @@ namespace NzbDrone.Common
|
|||
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
|
||||
PropagationFlags.None, controlType);
|
||||
|
||||
|
||||
directorySecurity.AddAccessRule(accessRule);
|
||||
directoryInfo.SetAccessControl(directorySecurity);
|
||||
}
|
||||
|
@ -466,32 +379,6 @@ namespace NzbDrone.Common
|
|||
return (DriveInfo.GetDrives().Where(x => x.DriveType == DriveType.Fixed).Select(x => x.Name)).ToArray();
|
||||
}
|
||||
|
||||
public long? GetTotalSize(string path)
|
||||
{
|
||||
Ensure.That(path, () => path).IsValidPath();
|
||||
|
||||
var root = GetPathRoot(path);
|
||||
|
||||
if (!FolderExists(root))
|
||||
throw new DirectoryNotFoundException(root);
|
||||
|
||||
if (OsInfo.IsLinux)
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetDriveInfoLinux(path).TotalSize;
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
Logger.ErrorException("Couldn't get total space for " + path, e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return DriveTotalSizeEx(root);
|
||||
}
|
||||
|
||||
public string GetVolumeLabel(string path)
|
||||
{
|
||||
var driveInfo = DriveInfo.GetDrives().SingleOrDefault(d => d.Name == path);
|
||||
|
@ -503,58 +390,5 @@ namespace NzbDrone.Common
|
|||
|
||||
return driveInfo.VolumeLabel;
|
||||
}
|
||||
|
||||
private static long DriveFreeSpaceEx(string folderName)
|
||||
{
|
||||
Ensure.That(folderName, () => folderName).IsValidPath();
|
||||
|
||||
if (!folderName.EndsWith("\\"))
|
||||
{
|
||||
folderName += '\\';
|
||||
}
|
||||
|
||||
ulong free = 0;
|
||||
ulong dummy1 = 0;
|
||||
ulong dummy2 = 0;
|
||||
|
||||
if (GetDiskFreeSpaceEx(folderName, out free, out dummy1, out dummy2))
|
||||
{
|
||||
return (long)free;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static long DriveTotalSizeEx(string folderName)
|
||||
{
|
||||
Ensure.That(folderName, () => folderName).IsValidPath();
|
||||
|
||||
if (!folderName.EndsWith("\\"))
|
||||
{
|
||||
folderName += '\\';
|
||||
}
|
||||
|
||||
ulong total = 0;
|
||||
ulong dummy1 = 0;
|
||||
ulong dummy2 = 0;
|
||||
|
||||
if (GetDiskFreeSpaceEx(folderName, out dummy1, out total, out dummy2))
|
||||
{
|
||||
return (long)total;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private DriveInfo GetDriveInfoLinux(string path)
|
||||
{
|
||||
var drives = DriveInfo.GetDrives();
|
||||
|
||||
return
|
||||
drives.Where(drive =>
|
||||
drive.IsReady && path.StartsWith(drive.Name, StringComparison.CurrentCultureIgnoreCase))
|
||||
.OrderByDescending(drive => drive.Name.Length)
|
||||
.First();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Principal;
|
||||
|
||||
namespace NzbDrone.Common.Disk
|
||||
{
|
||||
public interface IDiskProvider
|
||||
{
|
||||
long? GetAvailableSpace(string path);
|
||||
void InheritFolderPermissions(string filename);
|
||||
void SetPermissions(string path, string mask, string user, string group);
|
||||
long? GetTotalSize(string path);
|
||||
|
||||
DateTime GetLastFolderWrite(string path);
|
||||
DateTime GetLastFileWrite(string path);
|
||||
void EnsureFolder(string path);
|
||||
bool FolderExists(string path);
|
||||
bool FileExists(string path);
|
||||
bool FileExists(string path, bool caseSensitive);
|
||||
string[] GetDirectories(string path);
|
||||
string[] GetFiles(string path, SearchOption searchOption);
|
||||
long GetFolderSize(string path);
|
||||
long GetFileSize(string path);
|
||||
void CreateFolder(string path);
|
||||
void CopyFolder(string source, string destination);
|
||||
void MoveFolder(string source, string destination);
|
||||
void DeleteFile(string path);
|
||||
void MoveFile(string source, string destination);
|
||||
void DeleteFolder(string path, bool recursive);
|
||||
string ReadAllText(string filePath);
|
||||
void WriteAllText(string filename, string contents);
|
||||
void FileSetLastWriteTimeUtc(string path, DateTime dateTime);
|
||||
void FolderSetLastWriteTimeUtc(string path, DateTime dateTime);
|
||||
bool IsFileLocked(string path);
|
||||
string GetPathRoot(string path);
|
||||
string GetParentFolder(string path);
|
||||
void SetPermissions(string filename, WellKnownSidType accountSid, FileSystemRights rights, AccessControlType controlType);
|
||||
bool IsParent(string parentPath, string childPath);
|
||||
void SetFolderWriteTime(string path, DateTime time);
|
||||
FileAttributes GetFileAttributes(string path);
|
||||
void EmptyFolder(string path);
|
||||
string[] GetFixedDrives();
|
||||
string GetVolumeLabel(string path);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
|
||||
namespace NzbDrone.Common.EnvironmentInfo
|
||||
{
|
||||
public interface IAppFolderFactory
|
||||
{
|
||||
void Register();
|
||||
}
|
||||
|
||||
public class AppFolderFactory : IAppFolderFactory
|
||||
{
|
||||
private readonly IAppFolderInfo _appFolderInfo;
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public AppFolderFactory(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider)
|
||||
{
|
||||
_appFolderInfo = appFolderInfo;
|
||||
_diskProvider = diskProvider;
|
||||
_logger = NzbDroneLogger.GetLogger(this);
|
||||
}
|
||||
|
||||
public void Register()
|
||||
{
|
||||
_diskProvider.EnsureFolder(_appFolderInfo.AppDataFolder);
|
||||
|
||||
if (!OsInfo.IsLinux)
|
||||
{
|
||||
SetPermissions();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetPermissions()
|
||||
{
|
||||
try
|
||||
{
|
||||
_diskProvider.SetPermissions(_appFolderInfo.AppDataFolder, WellKnownSidType.WorldSid, FileSystemRights.FullControl, AccessControlType.Allow);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.WarnException("Coudn't set app folder permission", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ using System.Reflection;
|
|||
using System.Security.AccessControl;
|
||||
using System.Security.Principal;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
|
||||
namespace NzbDrone.Common.EnvironmentInfo
|
||||
|
@ -17,22 +18,15 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||
|
||||
public class AppFolderInfo : IAppFolderInfo
|
||||
{
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly Logger _logger;
|
||||
private readonly Environment.SpecialFolder DATA_SPECIAL_FOLDER = Environment.SpecialFolder.CommonApplicationData;
|
||||
|
||||
|
||||
public AppFolderInfo(IDiskProvider diskProvider, IStartupContext startupContext)
|
||||
public AppFolderInfo(IStartupContext startupContext)
|
||||
{
|
||||
_diskProvider = diskProvider;
|
||||
|
||||
if (OsInfo.IsLinux)
|
||||
{
|
||||
DATA_SPECIAL_FOLDER = Environment.SpecialFolder.ApplicationData;
|
||||
}
|
||||
|
||||
_logger = NzbDroneLogger.GetLogger(this);
|
||||
|
||||
if (startupContext.Args.ContainsKey(StartupContext.APPDATA))
|
||||
{
|
||||
AppDataFolder = startupContext.Args[StartupContext.APPDATA];
|
||||
|
@ -42,29 +36,8 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||
AppDataFolder = Path.Combine(Environment.GetFolderPath(DATA_SPECIAL_FOLDER, Environment.SpecialFolderOption.None), "NzbDrone");
|
||||
}
|
||||
|
||||
_diskProvider.EnsureFolder(AppDataFolder);
|
||||
|
||||
StartUpFolder = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
|
||||
TempFolder = Path.GetTempPath();
|
||||
|
||||
diskProvider.EnsureFolder(AppDataFolder);
|
||||
|
||||
if (!OsInfo.IsLinux)
|
||||
{
|
||||
SetPermissions();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetPermissions()
|
||||
{
|
||||
try
|
||||
{
|
||||
_diskProvider.SetPermissions(AppDataFolder, WellKnownSidType.WorldSid, FileSystemRights.FullControl, AccessControlType.Allow);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.WarnException("Coudn't set app folder permission", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public string AppDataFolder { get; private set; }
|
||||
|
|
|
@ -37,8 +37,6 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||
static RuntimeInfo()
|
||||
{
|
||||
IsProduction = InternalIsProduction();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public bool IsAdmin
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
|
@ -11,10 +12,15 @@ namespace NzbDrone.Common.Instrumentation
|
|||
{
|
||||
public static void Register(IStartupContext startupContext, bool updateApp, bool inConsole)
|
||||
{
|
||||
var appFolderInfo = new AppFolderInfo(new DiskProvider(), startupContext);
|
||||
var appFolderInfo = new AppFolderInfo(startupContext);
|
||||
|
||||
LogManager.Configuration = new LoggingConfiguration();
|
||||
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
RegisterDebugger();
|
||||
}
|
||||
|
||||
RegisterExceptron();
|
||||
|
||||
if (updateApp)
|
||||
|
@ -35,6 +41,18 @@ namespace NzbDrone.Common.Instrumentation
|
|||
LogManager.ReconfigExistingLoggers();
|
||||
}
|
||||
|
||||
private static void RegisterDebugger()
|
||||
{
|
||||
DebuggerTarget target = new DebuggerTarget();
|
||||
target.Name = "debuggerLogger";
|
||||
target.Layout = "[${level}] [${threadid}] ${logger}: ${message} ${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}";
|
||||
|
||||
var loggingRule = new LoggingRule("*", LogLevel.Trace, target);
|
||||
LogManager.Configuration.AddTarget("debugger", target);
|
||||
LogManager.Configuration.LoggingRules.Add(loggingRule);
|
||||
}
|
||||
|
||||
|
||||
private static void RegisterConsole()
|
||||
{
|
||||
var level = LogLevel.Trace;
|
||||
|
@ -55,8 +73,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||
LogManager.Configuration.LoggingRules.Add(loggingRule);
|
||||
}
|
||||
|
||||
|
||||
const string FileLogLayout = @"${date:format=yy-M-d HH\:mm\:ss.f}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}";
|
||||
const string FILE_LOG_LAYOUT = @"${date:format=yy-M-d HH\:mm\:ss.f}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}";
|
||||
|
||||
private static void RegisterAppFile(IAppFolderInfo appFolderInfo)
|
||||
{
|
||||
|
@ -73,7 +90,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||
fileTarget.MaxArchiveFiles = 5;
|
||||
fileTarget.EnableFileDelete = true;
|
||||
fileTarget.ArchiveNumbering = ArchiveNumberingMode.Rolling;
|
||||
fileTarget.Layout = FileLogLayout;
|
||||
fileTarget.Layout = FILE_LOG_LAYOUT;
|
||||
|
||||
var loggingRule = new LoggingRule("*", LogLevel.Info, fileTarget);
|
||||
|
||||
|
@ -81,8 +98,6 @@ namespace NzbDrone.Common.Instrumentation
|
|||
LogManager.Configuration.LoggingRules.Add(loggingRule);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void RegisterUpdateFile(IAppFolderInfo appFolderInfo)
|
||||
{
|
||||
var fileTarget = new FileTarget();
|
||||
|
@ -94,7 +109,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||
fileTarget.ConcurrentWrites = false;
|
||||
fileTarget.ConcurrentWriteAttemptDelay = 50;
|
||||
fileTarget.ConcurrentWriteAttempts = 100;
|
||||
fileTarget.Layout = FileLogLayout;
|
||||
fileTarget.Layout = FILE_LOG_LAYOUT;
|
||||
|
||||
var loggingRule = new LoggingRule("*", LogLevel.Trace, fileTarget);
|
||||
|
||||
|
@ -104,7 +119,6 @@ namespace NzbDrone.Common.Instrumentation
|
|||
|
||||
private static void RegisterExceptron()
|
||||
{
|
||||
|
||||
var exceptronTarget = new ExceptronTarget();
|
||||
var rule = new LoggingRule("*", LogLevel.Warn, exceptronTarget);
|
||||
|
||||
|
@ -112,7 +126,6 @@ namespace NzbDrone.Common.Instrumentation
|
|||
LogManager.Configuration.LoggingRules.Add(rule);
|
||||
}
|
||||
|
||||
|
||||
private static void RegisterLoggly()
|
||||
{
|
||||
var logglyTarger = new LogglyTarget();
|
||||
|
@ -122,6 +135,5 @@ namespace NzbDrone.Common.Instrumentation
|
|||
LogManager.Configuration.AddTarget("LogglyLogger", logglyTarger);
|
||||
LogManager.Configuration.LoggingRules.Add(rule);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -67,6 +67,7 @@
|
|||
<Compile Include="Composition\IContainer.cs" />
|
||||
<Compile Include="Composition\ContainerBuilderBase.cs" />
|
||||
<Compile Include="DateTimeExtensions.cs" />
|
||||
<Compile Include="Disk\DiskProviderBase.cs" />
|
||||
<Compile Include="EnsureThat\Ensure.cs" />
|
||||
<Compile Include="EnsureThat\EnsureBoolExtensions.cs" />
|
||||
<Compile Include="EnsureThat\EnsureCollectionExtensions.cs" />
|
||||
|
@ -85,6 +86,7 @@
|
|||
<Compile Include="EnsureThat\ExpressionExtensions.cs" />
|
||||
<Compile Include="EnsureThat\Param.cs" />
|
||||
<Compile Include="EnsureThat\Resources\ExceptionMessages.Designer.cs" />
|
||||
<Compile Include="EnvironmentInfo\AppFolderFactory.cs" />
|
||||
<Compile Include="EnvironmentInfo\BuildInfo.cs" />
|
||||
<Compile Include="EnvironmentInfo\StartupContext.cs" />
|
||||
<Compile Include="EnvironmentInfo\RuntimeInfo.cs" />
|
||||
|
@ -121,7 +123,7 @@
|
|||
<Compile Include="HttpProvider.cs" />
|
||||
<Compile Include="ConsoleService.cs" />
|
||||
<Compile Include="PathExtensions.cs" />
|
||||
<Compile Include="DiskProvider.cs" />
|
||||
<Compile Include="Disk\IDiskProvider.cs" />
|
||||
<Compile Include="EnvironmentInfo\AppFolderInfo.cs" />
|
||||
<Compile Include="Model\ProcessInfo.cs" />
|
||||
<Compile Include="Processes\ProcessProvider.cs" />
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications.Search;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
||||
{
|
||||
[TestFixture]
|
||||
public class SeriesSpecificationFixture : TestBase<SeriesSpecification>
|
||||
{
|
||||
private Series _series1;
|
||||
private Series _series2;
|
||||
private RemoteEpisode _remoteEpisode = new RemoteEpisode();
|
||||
private SearchCriteriaBase _searchCriteria = new SingleEpisodeSearchCriteria();
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series1 = Builder<Series>.CreateNew().With(s => s.Id = 1).Build();
|
||||
_series2 = Builder<Series>.CreateNew().With(s => s.Id = 2).Build();
|
||||
|
||||
_remoteEpisode.Series = _series1;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_series_doesnt_match()
|
||||
{
|
||||
_searchCriteria.Series = _series2;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_series_ids_match()
|
||||
{
|
||||
_searchCriteria.Series = _series1;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, _searchCriteria).Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ using System.Net;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Net;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Framework
|
||||
|
@ -22,12 +23,11 @@ namespace NzbDrone.Core.Test.Framework
|
|||
Mocker.SetConstant<IHttpProvider>(new HttpProvider(TestLogger));
|
||||
}
|
||||
|
||||
protected void UseRealDisk()
|
||||
{
|
||||
Mocker.SetConstant<IDiskProvider>(new DiskProvider());
|
||||
WithTempAsAppPath();
|
||||
}
|
||||
|
||||
// protected void UseRealDisk()
|
||||
// {
|
||||
// Mocker.SetConstant<IDiskProvider>(new DiskProvider());
|
||||
// WithTempAsAppPath();
|
||||
// }
|
||||
}
|
||||
|
||||
public abstract class CoreTest<TSubject> : CoreTest where TSubject : class
|
||||
|
|
|
@ -3,6 +3,7 @@ using FluentAssertions;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
|
|
@ -4,6 +4,7 @@ using FluentAssertions;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
@ -17,7 +18,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
|
|||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.SetConstant<IAppFolderInfo>(new AppFolderInfo(new DiskProvider(), Mocker.Resolve<IStartupContext>()));
|
||||
Mocker.SetConstant<IAppFolderInfo>(new AppFolderInfo(Mocker.Resolve<IStartupContext>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -5,6 +5,7 @@ using FizzWare.NBuilder;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
|
|
|
@ -6,6 +6,7 @@ using FizzWare.NBuilder;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
@ -24,12 +25,16 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeFileMovingServiceTests
|
|||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.With(s => s.Path = @"C:\Test\TV\Series")
|
||||
.Build();
|
||||
|
||||
_episodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
.With(f => f.Path = @"C:\Test\File.avi")
|
||||
.Build();
|
||||
|
||||
_localEpisode = Builder<LocalEpisode>.CreateNew()
|
||||
.With(l => l.Series = Builder<Series>.CreateNew().Build())
|
||||
.With(l => l.Series = _series)
|
||||
.With(l => l.Episodes = Builder<Episode>.CreateListOfSize(1).Build().ToList())
|
||||
.Build();
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ using FluentAssertions;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
|
|
@ -3,6 +3,7 @@ using FluentAssertions;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
|
|
@ -4,6 +4,7 @@ using FluentAssertions;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
|
|
@ -5,6 +5,7 @@ using FizzWare.NBuilder;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
|
|
@ -3,6 +3,7 @@ using FluentAssertions;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.MediaFiles.MediaInfo;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.Categories;
|
||||
|
|
|
@ -5,6 +5,7 @@ using Marr.Data;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
|
|
@ -118,6 +118,7 @@
|
|||
<Compile Include="DecisionEngineTests\CutoffSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\NotRestrictedReleaseSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\RssSync\ProperSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\Search\SeriesSpecificationFixture.cs" />
|
||||
<Compile Include="Download\DownloadApprovedReportsTests\DownloadApprovedFixture.cs" />
|
||||
<Compile Include="Download\DownloadApprovedReportsTests\GetQualifiedReportsFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\BlackholeProviderFixture.cs" />
|
||||
|
@ -208,7 +209,6 @@
|
|||
<Compile Include="DecisionEngineTests\HistorySpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\UpgradeDiskSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\QualityUpgradeSpecificationFixture.cs" />
|
||||
<Compile Include="ProviderTests\DiskProviderTests\FreeDiskSpaceFixture.cs" />
|
||||
<Compile Include="NotificationTests\ProwlProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\DiskProviderTests\ArchiveProviderFixture.cs" />
|
||||
<Compile Include="MediaFiles\DownloadedEpisodesImportServiceFixture.cs" />
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace NzbDrone.Core.Test.ParserTests
|
|||
[TestCase("The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", "The.Girls.Next.Door", 3, 6)]
|
||||
[TestCase("Degrassi.S10E27.WS.DSR.XviD-2HD", "Degrassi", 10, 27)]
|
||||
[TestCase("Parenthood.2010.S02E14.HDTV.XviD-LOL", "Parenthood 2010", 2, 14)]
|
||||
[TestCase("Hawaii Five 0 S01E19 720p WEB DL DD5 1 H 264 NT", "Hawaii Five", 1, 19)]
|
||||
[TestCase("Hawaii Five 0 S01E19 720p WEB DL DD5 1 H 264 NT", "Hawaii Five 0", 1, 19)]
|
||||
[TestCase("The Event S01E14 A Message Back 720p WEB DL DD5 1 H264 SURFER", "The Event", 1, 14)]
|
||||
[TestCase("Adam Hills In Gordon St Tonight S01E07 WS PDTV XviD FUtV", "Adam Hills In Gordon St Tonight", 1, 7)]
|
||||
[TestCase("Adam Hills In Gordon St Tonight S01E07 WS PDTV XviD FUtV", "Adam Hills In Gordon St Tonight", 1, 7)]
|
||||
|
@ -373,6 +373,9 @@ namespace NzbDrone.Core.Test.ParserTests
|
|||
[TestCase("The Venture Bros. (2004)", "venturebros2004")]
|
||||
[TestCase("Castle (2011)", "castle2011")]
|
||||
[TestCase("Adventure Time S02 720p HDTV x264 CRON", "adventuretime")]
|
||||
[TestCase("Hawaii Five 0", "hawaiifive0")]
|
||||
[TestCase("Match of the Day", "matchday")]
|
||||
[TestCase("Match of the Day 2", "matchday2")]
|
||||
public void parse_series_name(string postTitle, string title)
|
||||
{
|
||||
var result = Parser.Parser.ParseSeriesName(postTitle);
|
||||
|
@ -412,7 +415,7 @@ namespace NzbDrone.Core.Test.ParserTests
|
|||
result.Language.Should().Be(language);
|
||||
}
|
||||
|
||||
[TestCase("Hawaii Five 0 S01 720p WEB DL DD5 1 H 264 NT", "Hawaii Five", 1)]
|
||||
[TestCase("Hawaii Five 0 S01 720p WEB DL DD5 1 H 264 NT", "Hawaii Five 0", 1)]
|
||||
[TestCase("30 Rock S03 WS PDTV XviD FUtV", "30 Rock", 3)]
|
||||
[TestCase("The Office Season 4 WS PDTV XviD FUtV", "The Office", 4)]
|
||||
[TestCase("Eureka Season 1 720p WEB DL DD 5 1 h264 TjHD", "Eureka", 1)]
|
||||
|
|
|
@ -4,6 +4,7 @@ using FluentAssertions;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.IO;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.IO;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
|
|
@ -4,6 +4,7 @@ using System;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.IO;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
|
|
@ -7,6 +7,7 @@ using FluentAssertions;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
|
|
@ -5,6 +5,7 @@ using FluentAssertions;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
|
Binary file not shown.
|
@ -4,6 +4,7 @@ using FluentAssertions;
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Model;
|
||||
using NzbDrone.Common.Processes;
|
||||
|
@ -128,12 +129,10 @@ namespace NzbDrone.Core.Test.UpdateTests
|
|||
|
||||
updateSubFolder.Exists.Should().BeFalse();
|
||||
|
||||
Mocker.Resolve<DiskProvider>();
|
||||
Mocker.SetConstant<IArchiveService>(Mocker.Resolve<ArchiveService>());
|
||||
|
||||
Subject.Execute(new ApplicationUpdateCommand());
|
||||
|
||||
|
||||
updateSubFolder.Refresh();
|
||||
|
||||
updateSubFolder.Exists.Should().BeTrue();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
||||
namespace NzbDrone.Core.Blacklisting
|
||||
|
@ -7,9 +9,11 @@ namespace NzbDrone.Core.Blacklisting
|
|||
public interface IBlacklistService
|
||||
{
|
||||
bool Blacklisted(string sourceTitle);
|
||||
PagingSpec<Blacklist> Paged(PagingSpec<Blacklist> pagingSpec);
|
||||
void Delete(int id);
|
||||
}
|
||||
|
||||
public class BlacklistService : IBlacklistService, IHandle<DownloadFailedEvent>
|
||||
public class BlacklistService : IBlacklistService, IHandle<DownloadFailedEvent>, IExecute<ClearBlacklistCommand>
|
||||
{
|
||||
private readonly IBlacklistRepository _blacklistRepository;
|
||||
private readonly IRedownloadFailedDownloads _redownloadFailedDownloadService;
|
||||
|
@ -25,6 +29,16 @@ namespace NzbDrone.Core.Blacklisting
|
|||
return _blacklistRepository.Blacklisted(sourceTitle);
|
||||
}
|
||||
|
||||
public PagingSpec<Blacklist> Paged(PagingSpec<Blacklist> pagingSpec)
|
||||
{
|
||||
return _blacklistRepository.GetPaged(pagingSpec);
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
{
|
||||
_blacklistRepository.Delete(id);
|
||||
}
|
||||
|
||||
public void Handle(DownloadFailedEvent message)
|
||||
{
|
||||
var blacklist = new Blacklist
|
||||
|
@ -40,5 +54,10 @@ namespace NzbDrone.Core.Blacklisting
|
|||
|
||||
_redownloadFailedDownloadService.Redownload(message.SeriesId, message.EpisodeIds);
|
||||
}
|
||||
|
||||
public void Execute(ClearBlacklistCommand message)
|
||||
{
|
||||
_blacklistRepository.Purge();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
using NzbDrone.Core.Messaging.Commands;
|
||||
|
||||
namespace NzbDrone.Core.Blacklisting
|
||||
{
|
||||
public class ClearBlacklistCommand : Command
|
||||
{
|
||||
public override bool SendUpdatesToClient
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -278,12 +278,47 @@ namespace NzbDrone.Core.Configuration
|
|||
set { SetValue("CreateEmptySeriesFolders", value); }
|
||||
}
|
||||
|
||||
public string DownloadClientWorkingFolders
|
||||
public String DownloadClientWorkingFolders
|
||||
{
|
||||
get { return GetValue("DownloadClientWorkingFolders", "_UNPACK_|_FAILED_"); }
|
||||
set { SetValue("DownloadClientWorkingFolders", value); }
|
||||
}
|
||||
|
||||
public Boolean SetPermissionsLinux
|
||||
{
|
||||
get { return GetValueBoolean("SetPermissionsLinux", false); }
|
||||
|
||||
set { SetValue("SetPermissionsLinux", value); }
|
||||
}
|
||||
|
||||
public String FileChmod
|
||||
{
|
||||
get { return GetValue("FileChmod", "0644"); }
|
||||
|
||||
set { SetValue("FileChmod", value); }
|
||||
}
|
||||
|
||||
public String FolderChmod
|
||||
{
|
||||
get { return GetValue("FolderChmod", "0755"); }
|
||||
|
||||
set { SetValue("FolderChmod", value); }
|
||||
}
|
||||
|
||||
public String ChownUser
|
||||
{
|
||||
get { return GetValue("ChownUser", ""); }
|
||||
|
||||
set { SetValue("ChownUser", value); }
|
||||
}
|
||||
|
||||
public String ChownGroup
|
||||
{
|
||||
get { return GetValue("ChownGroup", ""); }
|
||||
|
||||
set { SetValue("ChownGroup", value); }
|
||||
}
|
||||
|
||||
private string GetValue(string key)
|
||||
{
|
||||
return GetValue(key, String.Empty);
|
||||
|
|
|
@ -42,5 +42,10 @@ namespace NzbDrone.Core.Configuration
|
|||
Boolean EnableFailedDownloadHandling { get; set; }
|
||||
Boolean CreateEmptySeriesFolders { get; set; }
|
||||
void SaveValues(Dictionary<string, object> configValues);
|
||||
Boolean SetPermissionsLinux { get; set; }
|
||||
String FileChmod { get; set; }
|
||||
String FolderChmod { get; set; }
|
||||
String ChownUser { get; set; }
|
||||
String ChownGroup { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,18 +210,20 @@ namespace NzbDrone.Core.Datastore
|
|||
|
||||
public virtual PagingSpec<TModel> GetPaged(PagingSpec<TModel> pagingSpec)
|
||||
{
|
||||
var pagingQuery = Query.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
|
||||
.Skip(pagingSpec.PagingOffset())
|
||||
.Take(pagingSpec.PageSize);
|
||||
|
||||
pagingSpec.Records = pagingQuery.ToList();
|
||||
|
||||
//TODO: Use the same query for count and records
|
||||
pagingSpec.TotalRecords = Count();
|
||||
pagingSpec.Records = GetPagedQuery(Query, pagingSpec).ToList();
|
||||
pagingSpec.TotalRecords = GetPagedQuery(Query, pagingSpec).GetRowCount();
|
||||
|
||||
return pagingSpec;
|
||||
}
|
||||
|
||||
protected virtual SortBuilder<TModel> GetPagedQuery(QueryBuilder<TModel> query, PagingSpec<TModel> pagingSpec)
|
||||
{
|
||||
return query.Where(pagingSpec.FilterExpression)
|
||||
.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
|
||||
.Skip(pagingSpec.PagingOffset())
|
||||
.Take(pagingSpec.PageSize);
|
||||
}
|
||||
|
||||
public void DeleteAll()
|
||||
{
|
||||
DataMapper.Delete<TModel>(c => c.Id > 0);
|
||||
|
|
|
@ -71,8 +71,6 @@ namespace NzbDrone.Core.Datastore
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
_migrationController.MigrateToLatest(connectionString, migrationType);
|
||||
|
||||
return new Database(() =>
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
using NLog;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
||||
{
|
||||
public class SeriesSpecification : IDecisionEngineSpecification
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
|
||||
public SeriesSpecification(Logger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public string RejectionReason
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Wrong series";
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria)
|
||||
{
|
||||
if (searchCriteria == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
_logger.Trace("Checking if series matches searched series");
|
||||
|
||||
if (remoteEpisode.Series.Id != searchCriteria.Series.Id)
|
||||
{
|
||||
_logger.Trace("Series {0} does not match {1}", remoteEpisode.Series, searchCriteria.Series);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Organizer;
|
||||
|
|
|
@ -67,22 +67,12 @@ namespace NzbDrone.Core.History
|
|||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public override PagingSpec<History> GetPaged(PagingSpec<History> pagingSpec)
|
||||
protected override SortBuilder<History> GetPagedQuery(QueryBuilder<History> query, PagingSpec<History> pagingSpec)
|
||||
{
|
||||
pagingSpec.Records = GetPagedQuery(pagingSpec).ToList();
|
||||
pagingSpec.TotalRecords = GetPagedQuery(pagingSpec).GetRowCount();
|
||||
var baseQuery = query.Join<History, Series>(JoinType.Inner, h => h.Series, (h, s) => h.SeriesId == s.Id)
|
||||
.Join<History, Episode>(JoinType.Inner, h => h.Episode, (h, e) => h.EpisodeId == e.Id);
|
||||
|
||||
return pagingSpec;
|
||||
}
|
||||
|
||||
private SortBuilder<History> GetPagedQuery(PagingSpec<History> pagingSpec)
|
||||
{
|
||||
return Query.Join<History, Series>(JoinType.Inner, h => h.Series, (h, s) => h.SeriesId == s.Id)
|
||||
.Join<History, Episode>(JoinType.Inner, h => h.Episode, (h, e) => h.EpisodeId == e.Id)
|
||||
.Where(pagingSpec.FilterExpression)
|
||||
.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
|
||||
.Skip(pagingSpec.PagingOffset())
|
||||
.Take(pagingSpec.PageSize);
|
||||
return base.GetPagedQuery(baseQuery, pagingSpec);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Housekeeping.Housekeepers
|
||||
{
|
||||
public class UpdateCleanTitleForSeries : IHousekeepingTask
|
||||
{
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public UpdateCleanTitleForSeries(ISeriesRepository seriesRepository, Logger logger)
|
||||
{
|
||||
_seriesRepository = seriesRepository;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Clean()
|
||||
{
|
||||
_logger.Trace("Updating CleanTitle for all series");
|
||||
|
||||
var series = _seriesRepository.All().ToList();
|
||||
|
||||
series.ForEach(s =>
|
||||
{
|
||||
s.CleanTitle = s.CleanTitle.CleanSeriesTitle();
|
||||
_seriesRepository.Update(s);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
using System.IO;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Instrumentation.Commands;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Serializer;
|
||||
|
||||
namespace NzbDrone.Core.MediaCover
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.IO;
|
|||
using System.Net;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
||||
|
|
|
@ -3,9 +3,10 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnsureThat;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
@ -23,16 +24,19 @@ namespace NzbDrone.Core.MediaFiles
|
|||
private readonly IEpisodeService _episodeService;
|
||||
private readonly IBuildFileNames _buildFileNames;
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly IConfigService _configService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public EpisodeFileMovingService(IEpisodeService episodeService,
|
||||
IBuildFileNames buildFileNames,
|
||||
IDiskProvider diskProvider,
|
||||
IConfigService configService,
|
||||
Logger logger)
|
||||
{
|
||||
_episodeService = episodeService;
|
||||
_buildFileNames = buildFileNames;
|
||||
_diskProvider = diskProvider;
|
||||
_configService = configService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
@ -75,7 +79,18 @@ namespace NzbDrone.Core.MediaFiles
|
|||
throw new SameFilenameException("File not moved, source and destination are the same", episodeFile.Path);
|
||||
}
|
||||
|
||||
_diskProvider.CreateFolder(new FileInfo(destinationFilename).DirectoryName);
|
||||
var directoryName = new FileInfo(destinationFilename).DirectoryName;
|
||||
|
||||
if (!_diskProvider.FolderExists(directoryName))
|
||||
{
|
||||
_diskProvider.CreateFolder(directoryName);
|
||||
SetFolderPermissions(directoryName);
|
||||
|
||||
if (!directoryName.PathEquals(series.Path))
|
||||
{
|
||||
SetFolderPermissions(series.Path);
|
||||
}
|
||||
}
|
||||
|
||||
_logger.Debug("Moving [{0}] > [{1}]", episodeFile.Path, destinationFilename);
|
||||
_diskProvider.MoveFile(episodeFile.Path, destinationFilename);
|
||||
|
@ -121,6 +136,42 @@ namespace NzbDrone.Core.MediaFiles
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
SetPermissions(destinationFilename, _configService.FileChmod);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetPermissions(string path, string permissions)
|
||||
{
|
||||
if (!_configService.SetPermissionsLinux)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_diskProvider.SetPermissions(path, permissions, _configService.ChownUser, _configService.ChownGroup);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex is UnauthorizedAccessException || ex is InvalidOperationException)
|
||||
{
|
||||
_logger.Debug("Unable to apply permissions to: ", path);
|
||||
_logger.TraceException(ex.Message, ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetFolderPermissions(string path)
|
||||
{
|
||||
SetPermissions(path, _configService.FolderChmod);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.IO;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.IO;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
{ ".asf", Quality.SDTV },
|
||||
{ ".asx", Quality.SDTV },
|
||||
{ ".ogm", Quality.SDTV },
|
||||
{ ".ogv", Quality.SDTV },
|
||||
{ ".m2v", Quality.SDTV },
|
||||
{ ".avi", Quality.SDTV },
|
||||
{ ".bin", Quality.SDTV },
|
||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.IO;
|
|||
using MediaInfoLib;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.MediaInfo
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.IO;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles
|
||||
|
|
|
@ -122,6 +122,7 @@
|
|||
<Compile Include="Blacklisting\Blacklist.cs" />
|
||||
<Compile Include="Blacklisting\BlacklistRepository.cs" />
|
||||
<Compile Include="Blacklisting\BlacklistService.cs" />
|
||||
<Compile Include="Blacklisting\ClearBlacklistCommand.cs" />
|
||||
<Compile Include="Configuration\Config.cs" />
|
||||
<Compile Include="Configuration\ConfigFileProvider.cs" />
|
||||
<Compile Include="Configuration\ConfigRepository.cs" />
|
||||
|
@ -218,6 +219,7 @@
|
|||
<Compile Include="DecisionEngine\Specifications\NotRestrictedReleaseSpecification.cs" />
|
||||
<Compile Include="DecisionEngine\Specifications\NotSampleSpecification.cs" />
|
||||
<Compile Include="DecisionEngine\Specifications\RssSync\ProperSpecification.cs" />
|
||||
<Compile Include="DecisionEngine\Specifications\Search\SeriesSpecification.cs" />
|
||||
<Compile Include="DecisionEngine\Specifications\Search\SeasonMatchSpecification.cs" />
|
||||
<Compile Include="DecisionEngine\Specifications\Search\DailyEpisodeMatchSpecification.cs" />
|
||||
<Compile Include="DecisionEngine\Specifications\AcceptableSizeSpecification.cs" />
|
||||
|
@ -256,6 +258,7 @@
|
|||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedHistoryItems.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedEpisodeFiles.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupAdditionalNamingSpecs.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\UpdateCleanTitleForSeries.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\FixFutureRunScheduledTasks.cs" />
|
||||
<Compile Include="Housekeeping\HousekeepingCommand.cs" />
|
||||
<Compile Include="Housekeeping\HousekeepingService.cs" />
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace NzbDrone.Core.Parser
|
|||
RegexOptions.IgnoreCase | RegexOptions.Compiled)
|
||||
};
|
||||
|
||||
private static readonly Regex NormalizeRegex = new Regex(@"((^|\W|_)(a|an|the|and|or|of)($|\W|_))|\W|_|(?:(?<=[^0-9]+)|\b)(?!(?:19\d{2}|20\d{2}))\d+(?=[^0-9ip]+|\b)",
|
||||
private static readonly Regex NormalizeRegex = new Regex(@"((?:\b|_)(a|an|the|and|or|of)(?:\b|_))|\W|_",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
private static readonly Regex SimpleTitleRegex = new Regex(@"480[i|p]|720[i|p]|1080[i|p]|[x|h|x\s|h\s]264|DD\W?5\W1|\<|\>|\?|\*|\:|\|",
|
||||
|
@ -153,7 +153,7 @@ namespace NzbDrone.Core.Parser
|
|||
|
||||
if (match.Count != 0)
|
||||
{
|
||||
Debug.WriteLine(regex);
|
||||
Logger.Trace(regex);
|
||||
try
|
||||
{
|
||||
var result = ParseMatchCollection(match);
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.DataAugmentation.Scene;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
@ -79,6 +80,7 @@ namespace NzbDrone.Core.Tv
|
|||
allEpisodes.AddRange(updateList);
|
||||
|
||||
AdjustMultiEpisodeAirTime(series, allEpisodes);
|
||||
SetAbsoluteEpisodeNumber(allEpisodes);
|
||||
|
||||
_episodeService.DeleteMany(existingEpisodes);
|
||||
_episodeService.UpdateMany(updateList);
|
||||
|
@ -132,12 +134,24 @@ namespace NzbDrone.Core.Tv
|
|||
foreach (var group in groups)
|
||||
{
|
||||
var episodeCount = 0;
|
||||
foreach (var episode in @group.OrderBy(e => e.SeasonNumber).ThenBy(e => e.EpisodeNumber))
|
||||
foreach (var episode in group.OrderBy(e => e.SeasonNumber).ThenBy(e => e.EpisodeNumber))
|
||||
{
|
||||
episode.AirDateUtc = episode.AirDateUtc.Value.AddMinutes(series.Runtime * episodeCount);
|
||||
episodeCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetAbsoluteEpisodeNumber(IEnumerable<Episode> allEpisodes)
|
||||
{
|
||||
var episodes = allEpisodes.Where(e => e.SeasonNumber > 0 && e.EpisodeNumber > 0)
|
||||
.OrderBy(e => e.SeasonNumber).ThenBy(e => e.EpisodeNumber)
|
||||
.ToList();
|
||||
|
||||
for (int i = 0; i < episodes.Count(); i++)
|
||||
{
|
||||
episodes[i].AbsoluteEpisodeNumber = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
using System.IO;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Processes;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
|
|
|
@ -17,6 +17,8 @@ namespace NzbDrone.Host
|
|||
|
||||
public static void Start(StartupContext startupContext, IUserAlert userAlert, Action<IContainer> startCallback = null)
|
||||
{
|
||||
LogTargets.Register(startupContext, false, true);
|
||||
|
||||
try
|
||||
{
|
||||
GlobalExceptionHandlers.Register();
|
||||
|
@ -30,6 +32,7 @@ namespace NzbDrone.Host
|
|||
}
|
||||
|
||||
_container = MainAppContainerBuilder.BuildContainer(startupContext);
|
||||
_container.Resolve<IAppFolderFactory>().Register();
|
||||
|
||||
var appMode = GetApplicationMode(startupContext);
|
||||
|
||||
|
@ -51,7 +54,6 @@ namespace NzbDrone.Host
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static void Start(ApplicationModes applicationModes)
|
||||
{
|
||||
if (!IsInUtilityMode(applicationModes))
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
using Nancy.Bootstrapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Nancy.Bootstrapper;
|
||||
using NzbDrone.Api;
|
||||
using NzbDrone.Common.Composition;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
@ -12,13 +15,31 @@ namespace NzbDrone.Host
|
|||
{
|
||||
public static IContainer BuildContainer(StartupContext args)
|
||||
{
|
||||
return new MainAppContainerBuilder(args).Container;
|
||||
var assemblies = new List<String>
|
||||
{
|
||||
"NzbDrone.Host",
|
||||
"NzbDrone.Common",
|
||||
"NzbDrone.Core",
|
||||
"NzbDrone.Api",
|
||||
"NzbDrone.SignalR"
|
||||
};
|
||||
|
||||
if (OsInfo.IsWindows)
|
||||
{
|
||||
assemblies.Add("NzbDrone.Windows");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
assemblies.Add("NzbDrone.Mono");
|
||||
}
|
||||
|
||||
return new MainAppContainerBuilder(args, assemblies.ToArray()).Container;
|
||||
}
|
||||
|
||||
private MainAppContainerBuilder(StartupContext args)
|
||||
: base(args, "NzbDrone.Host", "NzbDrone.Common", "NzbDrone.Core", "NzbDrone.Api", "NzbDrone.SignalR")
|
||||
private MainAppContainerBuilder(StartupContext args, string[] assemblies)
|
||||
: base(args, assemblies)
|
||||
{
|
||||
|
||||
AutoRegisterImplementations<NzbDronePersistentConnection>();
|
||||
|
||||
Container.Register(typeof(IBasicRepository<NamingConfig>), typeof(BasicRepository<NamingConfig>));
|
||||
|
|
|
@ -157,6 +157,10 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>xcopy /s /y "$(SolutionDir)\..\_output\NzbDrone.Mono.*" "$(TargetDir)"
|
||||
xcopy /s /y "$(SolutionDir)\..\_output\NzbDrone.Windows.*" "$(TargetDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Test.DiskProviderTests;
|
||||
|
||||
namespace NzbDrone.Mono.Test.DiskProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class DiskProviderFixture : DiskProviderFixtureBase<DiskProvider>
|
||||
{
|
||||
public DiskProviderFixture()
|
||||
{
|
||||
LinuxOnly();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Test.DiskProviderTests;
|
||||
|
||||
namespace NzbDrone.Mono.Test.DiskProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class FreeSpaceFixture : FreeSpaceFixtureBase<DiskProvider>
|
||||
{
|
||||
public FreeSpaceFixture()
|
||||
{
|
||||
LinuxOnly();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Test.DiskProviderTests;
|
||||
|
||||
namespace NzbDrone.Mono.Test.DiskProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class IsParentFixtureFixture : IsParentFixtureBase<DiskProvider>
|
||||
{
|
||||
public IsParentFixtureFixture()
|
||||
{
|
||||
LinuxOnly();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{40D72824-7D02-4A77-9106-8FE0EEA2B997}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NzbDrone.Mono.Test</RootNamespace>
|
||||
<AssemblyName>NzbDrone.Mono.Test</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DiskProviderTests\DiskProviderFixture.cs" />
|
||||
<Compile Include="DiskProviderTests\FreeSpaceFixture.cs" />
|
||||
<Compile Include="DiskProviderTests\IsParentFixture.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NzbDrone.Common.Test\NzbDrone.Common.Test.csproj">
|
||||
<Project>{bec74619-ddbb-4fba-b517-d3e20afc9997}</Project>
|
||||
<Name>NzbDrone.Common.Test</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Common\NzbDrone.Common.csproj">
|
||||
<Project>{f2be0fdf-6e47-4827-a420-dd4ef82407f8}</Project>
|
||||
<Name>NzbDrone.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Mono\NzbDrone.Mono.csproj">
|
||||
<Project>{15ad7579-a314-4626-b556-663f51d97cd1}</Project>
|
||||
<Name>NzbDrone.Mono</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Test.Common\NzbDrone.Test.Common.csproj">
|
||||
<Project>{caddfce0-7509-4430-8364-2074e1eefca2}</Project>
|
||||
<Name>NzbDrone.Test.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("NzbDrone.Mono.Test")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("NzbDrone.Mono.Test")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("45299d3c-34ff-48ca-9093-de2f037c38ac")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="2.6.2" targetFramework="net40" />
|
||||
</packages>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue