made file stamp a guid again

This commit is contained in:
Luke Pulverenti 2013-04-25 13:27:36 -04:00
parent b096f895ee
commit 7a5a1511cc
5 changed files with 25 additions and 15 deletions

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Localization;
@ -193,18 +194,23 @@ namespace MediaBrowser.Controller.Entities
/// <summary>
/// The _file system stamp
/// </summary>
private string _fileSystemStamp;
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 string FileSystemStamp
public Guid FileSystemStamp
{
get
{
return _fileSystemStamp ?? (_fileSystemStamp = GetFileSystemStamp());
if (!_fileSystemStamp.HasValue)
{
_fileSystemStamp = GetFileSystemStamp();
}
return _fileSystemStamp.Value;
}
}
@ -226,12 +232,12 @@ namespace MediaBrowser.Controller.Entities
/// comparison purposes to determine if the file system entries for this item have changed.
/// </summary>
/// <returns>Guid.</returns>
private string GetFileSystemStamp()
private Guid GetFileSystemStamp()
{
// If there's no path or the item is a file, there's nothing to do
if (LocationType != LocationType.FileSystem || !ResolveArgs.IsDirectory)
{
return string.Empty;
return Guid.Empty;
}
var sb = new StringBuilder();
@ -247,7 +253,7 @@ namespace MediaBrowser.Controller.Entities
sb.Append(file.cFileName);
}
return sb.ToString();
return sb.ToString().GetMD5();
}
/// <summary>

View File

@ -142,7 +142,7 @@ namespace MediaBrowser.Controller.Providers
// Save the file system stamp for future comparisons
if (RefreshOnFileSystemStampChange)
{
data.FileSystemStamp = GetCurrentFileSystemStamp(item);
data.FileStamp = GetCurrentFileSystemStamp(item);
}
item.ProviderData[Id] = data;
@ -229,7 +229,7 @@ namespace MediaBrowser.Controller.Providers
/// <returns><c>true</c> if [has file system stamp changed] [the specified item]; otherwise, <c>false</c>.</returns>
protected bool HasFileSystemStampChanged(BaseItem item, BaseProviderInfo providerInfo)
{
return !String.Equals(GetCurrentFileSystemStamp(item), providerInfo.FileSystemStamp);
return GetCurrentFileSystemStamp(item) != providerInfo.FileStamp;
}
/// <summary>
@ -287,7 +287,7 @@ namespace MediaBrowser.Controller.Providers
/// </summary>
/// <param name="item">The item.</param>
/// <returns>Guid.</returns>
private string GetCurrentFileSystemStamp(BaseItem item)
private Guid GetCurrentFileSystemStamp(BaseItem item)
{
if (UseParentFileSystemStamp(item) && item.Parent != null)
{

View File

@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.Providers
/// Gets or sets the file system stamp.
/// </summary>
/// <value>The file system stamp.</value>
public string FileSystemStamp { get; set; }
public Guid FileStamp { get; set; }
/// <summary>
/// Gets or sets the last refresh status.
/// </summary>

View File

@ -76,7 +76,11 @@ namespace MediaBrowser.Controller.Providers.Music
var ms = new MemoryStream();
JsonSerializer.SerializeToStream(result.artist, ms);
cancellationToken.ThrowIfCancellationRequested();
if (cancellationToken.IsCancellationRequested)
{
ms.Dispose();
cancellationToken.ThrowIfCancellationRequested();
}
await _providerManager.SaveToLibraryFilesystem(item, Path.Combine(item.MetaLocation, LocalMetaFileName), ms, cancellationToken).ConfigureAwait(false);

View File

@ -125,14 +125,14 @@ namespace MediaBrowser.Server.Implementations.Providers
BaseProviderInfo supportedProvidersInfo;
var supportedProvidersValue = string.Join("+", supportedProviders.Select(i => i.GetType().Name));
var supportedProvidersValue = string.Join(string.Empty, supportedProviders.Select(i => i.GetType().Name));
var providersChanged = false;
item.ProviderData.TryGetValue(_supportedProvidersKey, out supportedProvidersInfo);
if (supportedProvidersInfo != null)
{
// Force refresh if the supported providers have changed
providersChanged = force = force || !string.Equals(supportedProvidersInfo.FileSystemStamp, supportedProvidersValue);
providersChanged = force = force || !string.Equals(supportedProvidersInfo.CustomData, supportedProvidersValue);
// If providers have changed, clear provider info and update the supported providers hash
if (providersChanged)
@ -144,7 +144,7 @@ namespace MediaBrowser.Server.Implementations.Providers
if (providersChanged)
{
supportedProvidersInfo.FileSystemStamp = supportedProvidersValue;
supportedProvidersInfo.CustomData = supportedProvidersValue;
}
if (force) item.ClearMetaValues();