diff --git a/Log4ViewConfig.l4v b/Log4ViewConfig.l4v
index 4840586f0..d6c1f2252 100644
--- a/Log4ViewConfig.l4v
+++ b/Log4ViewConfig.l4v
@@ -2,695 +2,719 @@
1
-
- ALL
-
- false
- true
- true
- true
- false
-
- OFF
-
- 15
- <_charts z:Id="6" z:Size="0" />
- <_columns z:Id="7" z:Size="28">
-
-
- 46
-
- ClipRight
- Id
-
- -1
- 45
- 16
-
-
-
- 47
-
- ClipRight
- OriginalTime
-
- -1
- 120
- 16
-
-
-
- 48
-
- ClipRight
- Time
-
- 1
- 80
- 16
-
-
-
- 49
-
- ClipRight
- LocalTime
-
- -1
- 120
- 16
-
-
-
- 50
-
- ClipRight
- UtcTime
-
- -1
- 120
- 16
-
-
-
- 51
-
- ClipRight
- Key
-
- -1
- 120
- 16
-
-
-
- 52
-
- ClipRight
- Level
-
- -1
- 85
- 16
-
-
-
- 53
-
- ClipMiddle
- Logger
-
- 2
- 120
- 16
-
-
-
- 54
-
- ClipRight
- Source
-
- -1
- 90
- 16
-
-
-
- 55
-
- ClipRight
- Message
-
- 3
- 320
- 16
-
-
-
- 56
-
- ClipRight
- Thread
-
- -1
- 95
- 16
-
-
-
- 57
-
- ClipRight
- Host
-
- -1
- 90
- 16
-
-
-
- 58
-
- ClipRight
- Exception
-
- -1
- 120
- 16
-
-
-
- 59
-
- ClipRight
- Domain
-
- -1
- 90
- 16
-
-
-
- 60
-
- ClipRight
- Identity
-
- -1
- 120
- 16
-
-
-
- 61
-
- ClipRight
- User
-
- -1
- 90
- 16
-
-
-
- 62
-
- ClipRight
- Class
-
- -1
- 90
- 16
-
-
-
- 63
-
- ClipRight
- Method
-
- -1
- 120
- 16
-
-
-
- 64
-
- ClipRight
- File
-
- -1
- 120
- 16
-
-
-
- 65
-
- ClipRight
- Line
-
- -1
- 45
- 16
-
-
-
- 66
-
- ClipRight
- NDC
-
- -1
- 120
- 16
-
-
-
- 67
-
- ClipRight
- MDC
-
- -1
- 120
- 16
-
-
-
- 68
-
- ClipRight
- Comment
-
- -1
- 120
- 16
-
-
-
- 69
-
- ClipRight
- StackTrace
-
- -1
- 120
- 16
-
-
-
- 70
-
- ClipRight
- ProcessId
-
- -1
- 120
- 16
-
-
-
- 71
-
- ClipRight
- ThreadId
-
- -1
- 120
- 16
-
-
-
- 72
-
- ClipRight
- Date
-
- -1
- 70
- 16
-
-
-
- 73
-
- ClipRight
- CallStack
-
- -1
- 120
- 16
-
-
- <_filters z:Id="64" z:Size="0" />
- <_formats z:Id="65" z:Size="1">
-
-
- 0
-
- Message
-
-
-
-
-
- VERBOSE
-
-
-
- 2
-
-
- 0
-
- 0
- 0
-
- Tahoma
-
- 0
-
- 2
- 4290032820
-
-
- 8.25
-
-
-
-
-
- TRACE
-
-
-
- 3
-
-
- 0
-
- 0
- 0
-
- Tahoma
-
- 0
-
- 2
- 4288716960
-
-
- 8.25
-
-
-
-
-
- DEBUG
-
-
-
- 4
-
-
- 0
-
- 0
- 0
-
- Tahoma
-
- 0
-
- 2
- 4286743170
-
-
- 8.25
-
-
-
-
-
- INFO
-
-
-
- 5
-
-
- 0
-
- 0
- 0
-
- Tahoma
-
- 0
-
- 2
- 4278190080
-
-
- 8.25
-
-
-
-
-
- NOTICE
-
-
-
- 6
-
-
- 0
-
- 0
- 0
-
- Tahoma
-
- 0
-
- 2
- 4281957177
-
-
- 8.25
-
-
-
-
-
- WARN
-
-
-
- 7
-
-
- 0
-
- 0
- 0
-
- Tahoma
-
- 0
-
- 2
- 4294934528
-
-
- 8.25
-
-
-
-
-
- ERROR
-
-
-
- 8
-
-
- 0
-
- 0
- 0
-
- Tahoma
-
- 0
-
- 2
- 4294901760
-
-
- 8.25
-
-
-
-
-
- SEVERE
-
-
-
- 9
-
-
- 0
-
- 0
- 0
-
- Tahoma
-
- 0
-
- 2
- 4293067295
-
-
- 8.25
-
-
-
-
-
- CRITICAL
-
-
-
- 10
-
-
- 0
-
- 0
- 0
-
- Tahoma
-
- 0
-
- 2
- 4289400377
-
-
- 8.25
-
-
-
-
-
- ALERT
-
-
-
- 11
-
-
- 0
-
- 0
- 0
-
- Tahoma
-
- 0
-
- 2
- 4294902015
-
-
- 8.25
-
-
-
-
-
- FATAL
-
-
-
- 12
-
-
- 0
-
- 0
- 0
-
- Tahoma
-
- 0
-
- 2
- 4287309977
-
-
- 8.25
-
-
-
-
-
- EMERGENCY
-
-
-
- 13
-
-
- 0
-
- 0
- 0
-
- Tahoma
-
- 0
-
- 2
- 4285932413
-
-
- 8.25
-
-
-
-
- false
- Default Format Settings
-
-
- <_logLevels z:Id="119" z:Size="0" />
- <_loggers z:Id="120" z:Size="1">
-
-
- 45
-
-
-
- 14
-
-
- <_receivers z:Id="122" z:Size="1">
-
-
- 14
-
-
- 0
-
- 2
- 4293654015
-
- 500000
- Windows-1252
-
- Log4net
- NzbDrone Reciver
- XML
- 0
- 0001-01-01T00:00:00
- 0001-01-01T00:00:00
- 0
- 0
- Pacific Standard Time
- false
- 16
- localhost
- 20480
-
-
- <_sources z:Id="129" z:Size="0" />
+
+
+ 2
+
+ 17
+ <_receivers z:Id="3" z:Size="1">
+
+
+ 16
+
+
+ 0
+
+ 2
+ 4293654015
+
+ 500000
+ Windows-1252
+
+ ALL
+
+ Log4net
+ NzbDrone
+ XML
+ 0
+ 0001-01-01T00:00:00
+ 0001-01-01T00:00:00
+ 0
+ 0
+ Pacific Standard Time
+ false
+ 18
+ localhost
+ 20480
+ Udp
+
+
+ <_sources z:Id="12" z:Size="0" />
+
+
+
+ 3
+
+
+ false
+ true
+ true
+ true
+ false
+
+ OFF
+
+ 17
+ <_charts z:Id="16" z:Size="0" />
+ <_columns z:Id="17" z:Size="29">
+
+
+ 78
+
+ ClipRight
+ Id
+
+ -1
+ 45
+ 18
+
+
+
+ 79
+
+ ClipRight
+ OriginalTime
+
+ -1
+ 120
+ 18
+
+
+
+ 80
+
+ ClipRight
+ Time
+
+ 1
+ 80
+ 18
+
+
+
+ 81
+
+ ClipRight
+ LocalTime
+
+ -1
+ 120
+ 18
+
+
+
+ 82
+
+ ClipRight
+ UtcTime
+
+ -1
+ 120
+ 18
+
+
+
+ 83
+
+ ClipRight
+ Date
+
+ -1
+ 70
+ 18
+
+
+
+ 84
+
+ ClipRight
+ Key
+
+ -1
+ 120
+ 18
+
+
+
+ 85
+
+ ClipRight
+ Level
+
+ -1
+ 85
+ 18
+
+
+
+ 86
+
+ ClipMiddle
+ Logger
+
+ 2
+ 120
+ 18
+
+
+
+ 87
+
+ ClipRight
+ Source
+
+ -1
+ 90
+ 18
+
+
+
+ 88
+
+ ClipRight
+ Message
+
+ 3
+ 874
+ 18
+
+
+
+ 89
+
+ ClipRight
+ Thread
+
+ -1
+ 95
+ 18
+
+
+
+ 90
+
+ ClipRight
+ Host
+
+ -1
+ 90
+ 18
+
+
+
+ 91
+
+ ClipRight
+ Exception
+
+ -1
+ 120
+ 18
+
+
+
+ 92
+
+ ClipRight
+ Domain
+
+ -1
+ 90
+ 18
+
+
+
+ 93
+
+ ClipRight
+ Identity
+
+ -1
+ 120
+ 18
+
+
+
+ 94
+
+ ClipRight
+ User
+
+ -1
+ 90
+ 18
+
+
+
+ 95
+
+ ClipRight
+ Class
+
+ -1
+ 90
+ 18
+
+
+
+ 96
+
+ ClipRight
+ Method
+
+ -1
+ 120
+ 18
+
+
+
+ 97
+
+ ClipRight
+ File
+
+ -1
+ 120
+ 18
+
+
+
+ 98
+
+ ClipRight
+ Line
+
+ -1
+ 45
+ 18
+
+
+
+ 99
+
+ ClipRight
+ NDC
+
+ -1
+ 120
+ 18
+
+
+
+ 100
+
+ ClipRight
+ MDC
+
+ -1
+ 120
+ 18
+
+
+
+ 101
+
+ ClipRight
+ Comment
+
+ -1
+ 120
+ 18
+
+
+
+ 102
+
+ ClipRight
+ StackTrace
+
+ -1
+ 120
+ 18
+
+
+
+ 103
+
+ ClipRight
+ ProcessId
+
+ -1
+ 120
+ 18
+
+
+
+ 104
+
+ ClipRight
+ ThreadId
+
+ -1
+ 120
+ 18
+
+
+
+ 105
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Tahoma
+
+ 0
+
+ 2
+ 4294902015
+
+
+ 8.25
+
+
+
+
+
+ FATAL
+
+
+
+ 14
+
+
+ 0
+
+ 0
+ 0
+
+ Tahoma
+
+ 0
+
+ 2
+ 4287309977
+
+
+ 8.25
+
+
+
+
+
+ EMERGENCY
+
+
+
+ 15
+
+
+ 0
+
+ 0
+ 0
+
+ Tahoma
+
+ 0
+
+ 2
+ 4285932413
+
+
+ 8.25
+
+
+
+
+ false
+ Default Format Settings
+
+
+ <_logLevels z:Id="130" z:Size="0" />
+ <_loggers z:Id="131" z:Size="1">
+
+
+ 77
+
+
+
+ 16
+
+
+
+ 17
\ No newline at end of file
diff --git a/NzbDrone.Core.Test/MediaFileTests/DropFolderImportServiceFixture.cs b/NzbDrone.Core.Test/MediaFileTests/DropFolderImportServiceFixture.cs
index 5e3bd33b7..fa23461a4 100644
--- a/NzbDrone.Core.Test/MediaFileTests/DropFolderImportServiceFixture.cs
+++ b/NzbDrone.Core.Test/MediaFileTests/DropFolderImportServiceFixture.cs
@@ -1,5 +1,7 @@
+using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
@@ -9,7 +11,9 @@ using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.Commands;
using NzbDrone.Core.MediaFiles.EpisodeImport;
using NzbDrone.Core.Parser;
+using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
+using NzbDrone.Core.Tv;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.MediaFileTests
@@ -33,22 +37,22 @@ namespace NzbDrone.Core.Test.MediaFileTests
Mocker.GetMock().Setup(c => c.GetDirectories(It.IsAny()))
.Returns(_subFolders);
-
Mocker.GetMock().Setup(c => c.FolderExists(It.IsAny()))
.Returns(true);
Mocker.GetMock().SetupGet(c => c.DownloadedEpisodesFolder)
.Returns("c:\\drop\\");
-
+ Mocker.GetMock()
+ .Setup(s => s.Import(It.IsAny>(), true))
+ .Returns(new List());
}
- [Test]
- public void should_import_file()
+ private void GivenValidSeries()
{
- Subject.Execute(new DownloadedEpisodesScanCommand());
-
- VerifyImport();
+ Mocker.GetMock()
+ .Setup(s => s.GetSeries(It.IsAny()))
+ .Returns(Builder.CreateNew().Build());
}
[Test]
@@ -84,6 +88,60 @@ namespace NzbDrone.Core.Test.MediaFileTests
VerifyNoImport();
}
+ [Test]
+ public void should_not_import_if_folder_is_a_series_path()
+ {
+ Mocker.GetMock()
+ .Setup(s => s.SeriesPathExists(It.IsAny()))
+ .Returns(true);
+
+ Mocker.GetMock()
+ .Setup(c => c.GetVideoFiles(It.IsAny(), It.IsAny()))
+ .Returns(new string[0]);
+
+ Subject.Execute(new DownloadedEpisodesScanCommand());
+
+ Mocker.GetMock()
+ .Verify(v => v.GetSeries(It.IsAny()), Times.Never());
+ }
+
+ [Test]
+ public void should_not_delete_folder_if_no_files_were_imported()
+ {
+ Mocker.GetMock()
+ .Setup(s => s.Import(It.IsAny>(), false))
+ .Returns(new List());
+
+ Subject.Execute(new DownloadedEpisodesScanCommand());
+
+ Mocker.GetMock()
+ .Verify(v => v.GetFolderSize(It.IsAny()), Times.Never());
+ }
+
+ [Test]
+ public void should_delete_folder_if_files_were_imported()
+ {
+ GivenValidSeries();
+
+ var localEpisode = new LocalEpisode();
+
+ var imported = new List();
+ imported.Add(new ImportDecision(localEpisode));
+
+ Mocker.GetMock()
+ .Setup(s => s.GetImportDecisions(It.IsAny>(), It.IsAny()))
+ .Returns(imported);
+
+ Mocker.GetMock()
+ .Setup(s => s.Import(It.IsAny>(), true))
+ .Returns(imported);
+
+ Subject.Execute(new DownloadedEpisodesScanCommand());
+
+ Mocker.GetMock()
+ .Verify(v => v.DeleteFolder(It.IsAny(), true), Times.Once());
+ }
+
private void VerifyNoImport()
{
Mocker.GetMock().Verify(c => c.Import(It.IsAny>(), true),
diff --git a/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs b/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs
index df6346736..8a1e188ea 100644
--- a/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs
+++ b/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using NLog;
using NzbDrone.Common;
using NzbDrone.Common.Messaging;
@@ -64,11 +65,15 @@ namespace NzbDrone.Core.MediaFiles
{
try
{
- if (!_seriesService.SeriesPathExists(subFolder))
+ if (_seriesService.SeriesPathExists(subFolder))
{
- ProcessSubFolder(new DirectoryInfo(subFolder));
+ continue;
+ }
+
+ var importedFiles = ProcessSubFolder(new DirectoryInfo(subFolder));
- //Todo: We should make sure the file(s) are actually imported
+ if (importedFiles.Any())
+ {
if (_diskProvider.GetFolderSize(subFolder) < NotSampleSpecification.SampleSizeLimit)
{
_diskProvider.DeleteFolder(subFolder, true);
@@ -85,14 +90,7 @@ namespace NzbDrone.Core.MediaFiles
{
try
{
- var series = _parsingService.GetSeries(Path.GetFileNameWithoutExtension(videoFile));
-
- if (series == null)
- {
- _logger.Debug("Unknown Series for file: {0}", videoFile);
- }
-
- ProcessVideoFile(videoFile, series);
+ ProcessVideoFile(videoFile);
}
catch (Exception ex)
{
@@ -101,23 +99,31 @@ namespace NzbDrone.Core.MediaFiles
}
}
- private void ProcessSubFolder(DirectoryInfo subfolderInfo)
+ private List ProcessSubFolder(DirectoryInfo subfolderInfo)
{
var series = _parsingService.GetSeries(subfolderInfo.Name);
if (series == null)
{
_logger.Debug("Unknown Series {0}", subfolderInfo.Name);
- return;
+ return new List();
}
var videoFiles = _diskScanService.GetVideoFiles(subfolderInfo.FullName);
- ProcessFiles(videoFiles, series);
+ return ProcessFiles(videoFiles, series);
}
- private void ProcessVideoFile(string videoFile, Series series)
+ private void ProcessVideoFile(string videoFile)
{
+ var series = _parsingService.GetSeries(Path.GetFileNameWithoutExtension(videoFile));
+
+ if (series == null)
+ {
+ _logger.Debug("Unknown Series for file: {0}", videoFile);
+ return;
+ }
+
if (_diskProvider.IsFileLocked(new FileInfo(videoFile)))
{
_logger.Debug("[{0}] is currently locked by another process, skipping", videoFile);
@@ -127,10 +133,10 @@ namespace NzbDrone.Core.MediaFiles
ProcessFiles(new[] { videoFile }, series);
}
- private void ProcessFiles(IEnumerable videoFiles, Series series)
+ private List ProcessFiles(IEnumerable videoFiles, Series series)
{
var decisions = _importDecisionMaker.GetImportDecisions(videoFiles, series);
- _importApprovedEpisodes.Import(decisions, true);
+ return _importApprovedEpisodes.Import(decisions, true);
}
public void Execute(DownloadedEpisodesScanCommand message)