sorter cleanup

pull/702/head
Luke Pulverenti 11 years ago
parent a9f2a72d0b
commit daa532ba3f

@ -27,16 +27,22 @@ namespace MediaBrowser.Server.Implementations.FileSorting
{ {
var minFileBytes = options.MinFileSizeMb * 1024 * 1024; var minFileBytes = options.MinFileSizeMb * 1024 * 1024;
var allSeries = _libraryManager.RootFolder
.RecursiveChildren.OfType<Series>()
.Where(i => i.LocationType == LocationType.FileSystem)
.ToList();
var eligibleFiles = new DirectoryInfo(path) var eligibleFiles = new DirectoryInfo(path)
.EnumerateFiles("*", SearchOption.AllDirectories) .EnumerateFiles("*", SearchOption.AllDirectories)
.Where(i => EntityResolutionHelper.IsVideoFile(i.FullName) && i.Length >= minFileBytes) .Where(i => EntityResolutionHelper.IsVideoFile(i.FullName) && i.Length >= minFileBytes)
.ToList(); .ToList();
if (eligibleFiles.Count == 0)
{
// Nothing to do
return;
}
var allSeries = _libraryManager.RootFolder
.RecursiveChildren.OfType<Series>()
.Where(i => i.LocationType == LocationType.FileSystem)
.ToList();
foreach (var file in eligibleFiles) foreach (var file in eligibleFiles)
{ {
SortFile(file.FullName, options, allSeries); SortFile(file.FullName, options, allSeries);
@ -122,6 +128,11 @@ namespace MediaBrowser.Server.Implementations.FileSorting
{ {
var score = 0; var score = 0;
// TODO: Improve this
if (string.Equals(sortedName, series.Name, StringComparison.OrdinalIgnoreCase))
{
score++;
if (year.HasValue) if (year.HasValue)
{ {
if (series.ProductionYear.HasValue && year.Value == series.ProductionYear.Value) if (series.ProductionYear.HasValue && year.Value == series.ProductionYear.Value)
@ -129,16 +140,16 @@ namespace MediaBrowser.Server.Implementations.FileSorting
score++; score++;
} }
} }
// TODO: Improve this
if (string.Equals(sortedName, series.Name, StringComparison.OrdinalIgnoreCase))
{
score++;
} }
return new Tuple<Series, int>(series, score); return new Tuple<Series, int>(series, score);
} }
/// <summary>
/// Deletes the left over files.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="extensions">The extensions.</param>
private void DeleteLeftOverFiles(string path, IEnumerable<string> extensions) private void DeleteLeftOverFiles(string path, IEnumerable<string> extensions)
{ {
var eligibleFiles = new DirectoryInfo(path) var eligibleFiles = new DirectoryInfo(path)
@ -159,6 +170,10 @@ namespace MediaBrowser.Server.Implementations.FileSorting
} }
} }
/// <summary>
/// Deletes the empty folders.
/// </summary>
/// <param name="path">The path.</param>
private void DeleteEmptyFolders(string path) private void DeleteEmptyFolders(string path)
{ {
try try

Loading…
Cancel
Save