aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities/BaseItem.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Controller/Entities/BaseItem.cs')
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs38
1 files changed, 10 insertions, 28 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index b3b6361a7..ad997779d 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -565,8 +565,10 @@ namespace MediaBrowser.Controller.Entities
if (IsFolder || Parent != null)
{
+ options.DirectoryService = options.DirectoryService ?? new DirectoryService(Logger);
+
var files = locationType == LocationType.FileSystem || locationType == LocationType.Offline ?
- GetFileSystemChildren().ToList() :
+ GetFileSystemChildren(options.DirectoryService).ToList() :
new List<FileSystemInfo>();
await BeforeRefreshMetadata(options, files, cancellationToken).ConfigureAwait(false);
@@ -609,11 +611,11 @@ namespace MediaBrowser.Controller.Entities
}
}
- protected virtual IEnumerable<FileSystemInfo> GetFileSystemChildren()
+ protected virtual IEnumerable<FileSystemInfo> GetFileSystemChildren(DirectoryService directoryService)
{
var path = ContainingFolderPath;
- return new DirectoryInfo(path).EnumerateFileSystemInfos("*", SearchOption.TopDirectoryOnly);
+ return directoryService.GetFileSystemEntries(path);
}
private async Task<bool> RefreshLocalTrailers(IHasTrailers item, MetadataRefreshOptions options, List<FileSystemInfo> fileSystemChildren, CancellationToken cancellationToken)
@@ -851,29 +853,6 @@ namespace MediaBrowser.Controller.Entities
}
/// <summary>
- /// Finds the particular item by searching through our parents and, if not found there, loading from repo
- /// </summary>
- /// <param name="id">The id.</param>
- /// <returns>BaseItem.</returns>
- /// <exception cref="System.ArgumentException"></exception>
- protected BaseItem FindParentItem(Guid id)
- {
- if (id == Guid.Empty)
- {
- throw new ArgumentException();
- }
-
- var parent = Parent;
- while (parent != null && !parent.IsRoot)
- {
- if (parent.Id == id) return parent;
- parent = parent.Parent;
- }
-
- return null;
- }
-
- /// <summary>
/// Gets a value indicating whether this instance is folder.
/// </summary>
/// <value><c>true</c> if this instance is folder; otherwise, <c>false</c>.</value>
@@ -1226,10 +1205,13 @@ namespace MediaBrowser.Controller.Entities
/// <summary>
/// Validates that images within the item are still on the file system
/// </summary>
- public bool ValidateImages()
+ public bool ValidateImages(DirectoryService directoryService)
{
+ var allDirectories = ImageInfos.Select(i => System.IO.Path.GetDirectoryName(i.Path)).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
+ var allFiles = allDirectories.SelectMany(directoryService.GetFiles).Select(i => i.FullName).ToList();
+
var deletedImages = ImageInfos
- .Where(image => !File.Exists(image.Path))
+ .Where(image => !allFiles.Contains(image.Path, StringComparer.OrdinalIgnoreCase))
.ToList();
if (deletedImages.Count > 0)