mirror of https://github.com/Radarr/Radarr
Added GetDirectorySize to DiskProvider
Removed search folder from disk provider
This commit is contained in:
parent
8b0c8afb81
commit
3dd8e7240e
|
@ -39,31 +39,6 @@ namespace NzbDrone.Core.Test.Framework
|
|||
return database;
|
||||
}
|
||||
|
||||
public static DiskProvider GetStandardDisk(int seasons, int episodes)
|
||||
{
|
||||
var mock = new Mock<DiskProvider>();
|
||||
mock.Setup(c => c.GetDirectories(It.IsAny<String>())).Returns(StandardSeries);
|
||||
mock.Setup(c => c.FolderExists(It.Is<String>(d => StandardSeries.Contains(d)))).Returns(true);
|
||||
|
||||
|
||||
foreach (var series in StandardSeries)
|
||||
{
|
||||
var file = new List<String>();
|
||||
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)
|
||||
{
|
||||
return Builder<Series>.CreateNew()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
|
@ -21,9 +22,14 @@ namespace NzbDrone.Core.Providers.Core
|
|||
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)
|
||||
|
|
|
@ -196,7 +196,7 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
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();
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
|||
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)
|
||||
|
|
Loading…
Reference in New Issue