diff --git a/NzbDrone.Core.Test/Framework/MockLib.cs b/NzbDrone.Core.Test/Framework/MockLib.cs index a68f47568..9cf224e7f 100644 --- a/NzbDrone.Core.Test/Framework/MockLib.cs +++ b/NzbDrone.Core.Test/Framework/MockLib.cs @@ -39,32 +39,7 @@ public static IDatabase GetEmptyDatabase(bool enableLogging = false, string file return database; } - public static DiskProvider GetStandardDisk(int seasons, int episodes) - { - var mock = new Mock(); - mock.Setup(c => c.GetDirectories(It.IsAny())).Returns(StandardSeries); - mock.Setup(c => c.FolderExists(It.Is(d => StandardSeries.Contains(d)))).Returns(true); - - - foreach (var series in StandardSeries) - { - var file = new List(); - for (int s = 0; s < seasons; s++) - { - for (int e = 0; e < episodes; e++) - { - file.Add(String.Format("{0}\\Seasons {1}\\myepname.S{1:00}E{2:00}.avi", series, s, e)); - } - } - - string series1 = series; - mock.Setup(c => c.GetFiles(series1, "*.avi", SearchOption.AllDirectories)).Returns(file.ToArray()); - } - - return mock.Object; - } - - public static Series GetFakeSeries(int id, string title) + public static Series GetFakeSeries(int id, string title) { return Builder.CreateNew() .With(c => c.SeriesId = id) diff --git a/NzbDrone.Core/Providers/Core/DiskProvider.cs b/NzbDrone.Core/Providers/Core/DiskProvider.cs index 8e8ae2cb0..3a22a4328 100644 --- a/NzbDrone.Core/Providers/Core/DiskProvider.cs +++ b/NzbDrone.Core/Providers/Core/DiskProvider.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Collections.Generic; using System.IO; @@ -21,9 +22,14 @@ public virtual string[] GetDirectories(string path) return Directory.GetDirectories(path); } - public virtual string[] GetFiles(string path, string pattern, SearchOption searchOption) + public virtual string[] GetFiles(string path, SearchOption searchOption) { - return Directory.GetFiles(path, pattern, searchOption); + return Directory.GetFiles(path, "*.*", searchOption); + } + + public virtual long GetDirectorySize(string path) + { + return GetFiles(path, SearchOption.AllDirectories).Sum(e => new FileInfo(e).Length); } public virtual long GetSize(string path) diff --git a/NzbDrone.Core/Providers/DiskScanProvider.cs b/NzbDrone.Core/Providers/DiskScanProvider.cs index 456d7349e..d3fc5e6c6 100644 --- a/NzbDrone.Core/Providers/DiskScanProvider.cs +++ b/NzbDrone.Core/Providers/DiskScanProvider.cs @@ -196,7 +196,7 @@ private List GetVideoFiles(string path) { Logger.Debug("Scanning '{0}' for episodes", path); - var filesOnDisk = _diskProvider.GetFiles(path, "*.*", SearchOption.AllDirectories); + var filesOnDisk = _diskProvider.GetFiles(path, SearchOption.AllDirectories); var mediaFileList = filesOnDisk.Where(c => MediaExtentions.Contains(Path.GetExtension(c).ToLower())).ToList(); diff --git a/NzbDrone.Core/Providers/Jobs/PostDownloadScanJob.cs b/NzbDrone.Core/Providers/Jobs/PostDownloadScanJob.cs index 241fcdb39..b26eab842 100644 --- a/NzbDrone.Core/Providers/Jobs/PostDownloadScanJob.cs +++ b/NzbDrone.Core/Providers/Jobs/PostDownloadScanJob.cs @@ -88,7 +88,7 @@ public virtual void Start(ProgressNotification notification, int targetId) importedFiles.ForEach(file => _diskScanProvider.MoveEpisodeFile(file)); //Delete the folder only if all files were removed - if (_diskProvider.GetFiles(subfolder, "*.*", SearchOption.AllDirectories).Length == 0) + if (_diskProvider.GetFiles(subfolder, SearchOption.AllDirectories).Length == 0) _diskProvider.DeleteFolder(subfolder, false); } catch (Exception e)