mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
limit the extensions that are factored into the file stamp check
This commit is contained in:
parent
9b6e0c88f2
commit
d32c71ca39
@ -219,29 +219,6 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The _file system stamp
|
|
||||||
/// </summary>
|
|
||||||
private Guid? _fileSystemStamp;
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a directory stamp, in the form of a string, that can be used for
|
|
||||||
/// comparison purposes to determine if the file system entries for this item have changed.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The file system stamp.</value>
|
|
||||||
[IgnoreDataMember]
|
|
||||||
public Guid FileSystemStamp
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (!_fileSystemStamp.HasValue)
|
|
||||||
{
|
|
||||||
_fileSystemStamp = GetFileSystemStamp();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _fileSystemStamp.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the type of the media.
|
/// Gets the type of the media.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -255,49 +232,6 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a directory stamp, in the form of a string, that can be used for
|
|
||||||
/// comparison purposes to determine if the file system entries for this item have changed.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Guid.</returns>
|
|
||||||
private Guid GetFileSystemStamp()
|
|
||||||
{
|
|
||||||
// If there's no path or the item is a file, there's nothing to do
|
|
||||||
if (LocationType != LocationType.FileSystem)
|
|
||||||
{
|
|
||||||
return Guid.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!ResolveArgs.IsDirectory)
|
|
||||||
{
|
|
||||||
return Guid.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
Logger.ErrorException("Error determining if path is directory: {0}", ex, ResolveArgs.Path);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
var sb = new StringBuilder();
|
|
||||||
|
|
||||||
// Record the name of each file
|
|
||||||
// Need to sort these because accoring to msdn docs, our i/o methods are not guaranteed in any order
|
|
||||||
foreach (var file in ResolveArgs.FileSystemChildren
|
|
||||||
.OrderBy(f => f.Name))
|
|
||||||
{
|
|
||||||
sb.Append(file.Name);
|
|
||||||
}
|
|
||||||
foreach (var file in ResolveArgs.MetadataFiles.OrderBy(f => f.Name))
|
|
||||||
{
|
|
||||||
sb.Append(file.Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.ToString().GetMD5();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _resolve args
|
/// The _resolve args
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -338,9 +272,6 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
{
|
{
|
||||||
_resolveArgs = value;
|
_resolveArgs = value;
|
||||||
_resolveArgsInitialized = value != null;
|
_resolveArgsInitialized = value != null;
|
||||||
|
|
||||||
// Null this out so that it can be lazy loaded again
|
|
||||||
_fileSystemStamp = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Folder : BaseItem
|
public class Folder : BaseItem
|
||||||
{
|
{
|
||||||
private static readonly TypeMapper _typeMapper = new TypeMapper();
|
private static readonly TypeMapper TypeMapper = new TypeMapper();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether this instance is folder.
|
/// Gets a value indicating whether this instance is folder.
|
||||||
@ -883,7 +883,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
{
|
{
|
||||||
var type = child.Type;
|
var type = child.Type;
|
||||||
|
|
||||||
var itemType = _typeMapper.GetType(type);
|
var itemType = TypeMapper.GetType(type);
|
||||||
|
|
||||||
if (itemType == null)
|
if (itemType == null)
|
||||||
{
|
{
|
||||||
|
@ -16,6 +16,13 @@ namespace MediaBrowser.Controller.Library
|
|||||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||||
bool Supports(BaseItem item);
|
bool Supports(BaseItem item);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the save path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <returns>System.String.</returns>
|
||||||
|
string GetSavePath(BaseItem item);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Saves the specified item.
|
/// Saves the specified item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
using MediaBrowser.Common.Extensions;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using System;
|
using System;
|
||||||
@ -39,7 +43,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
protected static readonly Task<bool> FalseTaskResult = Task.FromResult(false);
|
protected static readonly Task<bool> FalseTaskResult = Task.FromResult(false);
|
||||||
|
|
||||||
protected static readonly SemaphoreSlim XmlParsingResourcePool = new SemaphoreSlim(5, 5);
|
protected static readonly SemaphoreSlim XmlParsingResourcePool = new SemaphoreSlim(5, 5);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Supportses the specified item.
|
/// Supportses the specified item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -228,7 +232,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,6 +286,11 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual string[] FilestampExtensions
|
||||||
|
{
|
||||||
|
get { return new string[] { }; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines if the parent's file system stamp should be used for comparison
|
/// Determines if the parent's file system stamp should be used for comparison
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -302,10 +311,79 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
{
|
{
|
||||||
if (UseParentFileSystemStamp(item) && item.Parent != null)
|
if (UseParentFileSystemStamp(item) && item.Parent != null)
|
||||||
{
|
{
|
||||||
return item.Parent.FileSystemStamp;
|
return GetFileSystemStamp(item.Parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
return item.FileSystemStamp;
|
return GetFileSystemStamp(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the file system stamp.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <returns>Guid.</returns>
|
||||||
|
private Guid GetFileSystemStamp(BaseItem item)
|
||||||
|
{
|
||||||
|
// If there's no path or the item is a file, there's nothing to do
|
||||||
|
if (item.LocationType != LocationType.FileSystem)
|
||||||
|
{
|
||||||
|
return Guid.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemResolveArgs resolveArgs;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
resolveArgs = item.ResolveArgs;
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
Logger.ErrorException("Error determining if path is directory: {0}", ex, item.Path);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!resolveArgs.IsDirectory)
|
||||||
|
{
|
||||||
|
return Guid.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
var extensions = FilestampExtensions;
|
||||||
|
|
||||||
|
// Record the name of each file
|
||||||
|
// Need to sort these because accoring to msdn docs, our i/o methods are not guaranteed in any order
|
||||||
|
foreach (var file in resolveArgs.FileSystemChildren
|
||||||
|
.Where(i => IncludeInFileStamp(i, extensions))
|
||||||
|
.OrderBy(f => f.Name))
|
||||||
|
{
|
||||||
|
sb.Append(file.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var file in resolveArgs.MetadataFiles
|
||||||
|
.Where(i => IncludeInFileStamp(i, extensions))
|
||||||
|
.OrderBy(f => f.Name))
|
||||||
|
{
|
||||||
|
sb.Append(file.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString().GetMD5();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Includes the in file stamp.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file">The file.</param>
|
||||||
|
/// <param name="extensions">The extensions.</param>
|
||||||
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||||
|
private bool IncludeInFileStamp(FileSystemInfo file, string[] extensions)
|
||||||
|
{
|
||||||
|
if ((file.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return extensions.Length == 0 || extensions.Contains(file.Extension, StringComparer.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,6 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The provider version.</value>
|
/// <value>The provider version.</value>
|
||||||
public string ProviderVersion { get; set; }
|
public string ProviderVersion { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// Contains a has of data that can be used to determine if the provider should refresh again
|
|
||||||
/// </summary>
|
|
||||||
public Guid Data { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -53,6 +53,18 @@ namespace MediaBrowser.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the filestamp extensions.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The filestamp extensions.</value>
|
||||||
|
protected override string[] FilestampExtensions
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return BaseItem.SupportedImageExtensions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -54,7 +54,7 @@ namespace MediaBrowser.Providers
|
|||||||
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
||||||
{
|
{
|
||||||
// Force a refresh if the IBN path changed
|
// Force a refresh if the IBN path changed
|
||||||
if (providerInfo.Data != ConfigurationManager.ApplicationPaths.ItemsByNamePath.GetMD5())
|
if (providerInfo.FileStamp != ConfigurationManager.ApplicationPaths.ItemsByNamePath.GetMD5())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ namespace MediaBrowser.Providers
|
|||||||
item.ProviderData[Id] = data;
|
item.ProviderData[Id] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.Data = ConfigurationManager.ApplicationPaths.ItemsByNamePath.GetMD5();
|
data.FileStamp = ConfigurationManager.ApplicationPaths.ItemsByNamePath.GetMD5();
|
||||||
SetLastRefreshed(item, DateTime.UtcNow);
|
SetLastRefreshed(item, DateTime.UtcNow);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -67,6 +67,18 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the filestamp extensions.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The filestamp extensions.</value>
|
||||||
|
protected override string[] FilestampExtensions
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new[] { ".srt" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Supports video files and dvd structures
|
/// Supports video files and dvd structures
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -251,7 +263,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
var chapters = data.Chapters ?? new List<ChapterInfo>();
|
var chapters = data.Chapters ?? new List<ChapterInfo>();
|
||||||
|
|
||||||
if (video.VideoType == VideoType.BluRay || (video.IsoType.HasValue && video.IsoType.Value == IsoType.BluRay))
|
if (video.VideoType == VideoType.BluRay || (video.IsoType.HasValue && video.IsoType.Value == IsoType.BluRay))
|
||||||
{
|
{
|
||||||
var inputPath = isoMount != null ? isoMount.MountedPath : video.Path;
|
var inputPath = isoMount != null ? isoMount.MountedPath : video.Path;
|
||||||
|
@ -50,7 +50,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
{
|
{
|
||||||
// If song metadata has changed and we don't have an mbid, refresh
|
// If song metadata has changed and we don't have an mbid, refresh
|
||||||
if (string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Musicbrainz)) &&
|
if (string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Musicbrainz)) &&
|
||||||
GetComparisonData(item as MusicAlbum) != providerInfo.Data)
|
GetComparisonData(item as MusicAlbum) != providerInfo.FileStamp)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
item.ProviderData[Id] = data;
|
item.ProviderData[Id] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.Data = GetComparisonData(item as MusicAlbum);
|
data.FileStamp = GetComparisonData(item as MusicAlbum);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<LastfmGetAlbumResult> GetAlbumResult(BaseItem item, CancellationToken cancellationToken)
|
private async Task<LastfmGetAlbumResult> GetAlbumResult(BaseItem item, CancellationToken cancellationToken)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using System.IO;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities;
|
|
||||||
using MediaBrowser.Controller.Entities.Movies;
|
using MediaBrowser.Controller.Entities.Movies;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -46,11 +46,19 @@ namespace MediaBrowser.Providers.Savers
|
|||||||
{
|
{
|
||||||
var video = (Video)item;
|
var video = (Video)item;
|
||||||
|
|
||||||
var directory = video.VideoType == VideoType.Iso || video.VideoType == VideoType.VideoFile ? Path.GetDirectoryName(video.Path) : video.Path;
|
var xmlFilePath = GetSavePath(item);
|
||||||
|
|
||||||
var xmlFilePath = Path.Combine(directory, "movie.xml");
|
|
||||||
|
|
||||||
return Task.Run(() => { });
|
return Task.Run(() => { });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string GetSavePath(BaseItem item)
|
||||||
|
{
|
||||||
|
var video = (Video)item;
|
||||||
|
|
||||||
|
var directory = video.VideoType == VideoType.Iso || video.VideoType == VideoType.VideoFile ? Path.GetDirectoryName(video.Path) : video.Path;
|
||||||
|
|
||||||
|
return Path.Combine(directory, "movie.xml");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,18 @@ namespace MediaBrowser.Providers.TV
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the filestamp extensions.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The filestamp extensions.</value>
|
||||||
|
protected override string[] FilestampExtensions
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return BaseItem.SupportedImageExtensions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user