fixed xml providers running over and over

This commit is contained in:
Luke Pulverenti 2013-10-01 14:24:27 -04:00
parent 900266eb54
commit 3d40c5ba36
42 changed files with 323 additions and 395 deletions

View File

@ -258,15 +258,7 @@ namespace MediaBrowser.Api
{ {
hasExited = process.HasExited; hasExited = process.HasExited;
} }
catch (Win32Exception ex) catch (Exception ex)
{
Logger.ErrorException("Error determining if ffmpeg process has exited for {0}", ex, job.Path);
}
catch (InvalidOperationException ex)
{
Logger.ErrorException("Error determining if ffmpeg process has exited for {0}", ex, job.Path);
}
catch (NotSupportedException ex)
{ {
Logger.ErrorException("Error determining if ffmpeg process has exited for {0}", ex, job.Path); Logger.ErrorException("Error determining if ffmpeg process has exited for {0}", ex, job.Path);
} }

View File

@ -358,10 +358,7 @@ namespace MediaBrowser.Api.Playback
{ {
var parentPath = Path.GetDirectoryName(path); var parentPath = Path.GetDirectoryName(path);
if (!Directory.Exists(parentPath)) Directory.CreateDirectory(parentPath);
{
Directory.CreateDirectory(parentPath);
}
var task = MediaEncoder.ExtractTextSubtitle(inputPath, type, subtitleStream.Index, offset, path, CancellationToken.None); var task = MediaEncoder.ExtractTextSubtitle(inputPath, type, subtitleStream.Index, offset, path, CancellationToken.None);
@ -396,10 +393,7 @@ namespace MediaBrowser.Api.Playback
{ {
var parentPath = Path.GetDirectoryName(path); var parentPath = Path.GetDirectoryName(path);
if (!Directory.Exists(parentPath)) Directory.CreateDirectory(parentPath);
{
Directory.CreateDirectory(parentPath);
}
var task = MediaEncoder.ConvertTextSubtitleToAss(subtitleStream.Path, path, subtitleStream.Language, offset, CancellationToken.None); var task = MediaEncoder.ConvertTextSubtitleToAss(subtitleStream.Path, path, subtitleStream.Language, offset, CancellationToken.None);
@ -599,10 +593,7 @@ namespace MediaBrowser.Api.Playback
{ {
var parentPath = Path.GetDirectoryName(outputPath); var parentPath = Path.GetDirectoryName(outputPath);
if (!Directory.Exists(parentPath)) Directory.CreateDirectory(parentPath);
{
Directory.CreateDirectory(parentPath);
}
var video = state.Item as Video; var video = state.Item as Video;
@ -648,7 +639,7 @@ namespace MediaBrowser.Api.Playback
{ {
process.Start(); process.Start();
} }
catch (Win32Exception ex) catch (Exception ex)
{ {
Logger.ErrorException("Error starting ffmpeg", ex); Logger.ErrorException("Error starting ffmpeg", ex);

View File

@ -72,10 +72,7 @@ namespace MediaBrowser.Common.Implementations
{ {
_dataDirectory = Path.Combine(ProgramDataPath, "data"); _dataDirectory = Path.Combine(ProgramDataPath, "data");
if (!Directory.Exists(_dataDirectory)) Directory.CreateDirectory(_dataDirectory);
{
Directory.CreateDirectory(_dataDirectory);
}
} }
return _dataDirectory; return _dataDirectory;
@ -98,10 +95,7 @@ namespace MediaBrowser.Common.Implementations
{ {
_imageCachePath = Path.Combine(CachePath, "images"); _imageCachePath = Path.Combine(CachePath, "images");
if (!Directory.Exists(_imageCachePath)) Directory.CreateDirectory(_imageCachePath);
{
Directory.CreateDirectory(_imageCachePath);
}
} }
return _imageCachePath; return _imageCachePath;
@ -123,10 +117,7 @@ namespace MediaBrowser.Common.Implementations
if (_pluginsPath == null) if (_pluginsPath == null)
{ {
_pluginsPath = Path.Combine(ProgramDataPath, "plugins"); _pluginsPath = Path.Combine(ProgramDataPath, "plugins");
if (!Directory.Exists(_pluginsPath)) Directory.CreateDirectory(_pluginsPath);
{
Directory.CreateDirectory(_pluginsPath);
}
} }
return _pluginsPath; return _pluginsPath;
@ -148,10 +139,7 @@ namespace MediaBrowser.Common.Implementations
if (_pluginConfigurationsPath == null) if (_pluginConfigurationsPath == null)
{ {
_pluginConfigurationsPath = Path.Combine(PluginsPath, "configurations"); _pluginConfigurationsPath = Path.Combine(PluginsPath, "configurations");
if (!Directory.Exists(_pluginConfigurationsPath)) Directory.CreateDirectory(_pluginConfigurationsPath);
{
Directory.CreateDirectory(_pluginConfigurationsPath);
}
} }
return _pluginConfigurationsPath; return _pluginConfigurationsPath;
@ -170,10 +158,7 @@ namespace MediaBrowser.Common.Implementations
if (_tempUpdatePath == null) if (_tempUpdatePath == null)
{ {
_tempUpdatePath = Path.Combine(ProgramDataPath, "updates"); _tempUpdatePath = Path.Combine(ProgramDataPath, "updates");
if (!Directory.Exists(_tempUpdatePath)) Directory.CreateDirectory(_tempUpdatePath);
{
Directory.CreateDirectory(_tempUpdatePath);
}
} }
return _tempUpdatePath; return _tempUpdatePath;
@ -195,10 +180,7 @@ namespace MediaBrowser.Common.Implementations
if (_logDirectoryPath == null) if (_logDirectoryPath == null)
{ {
_logDirectoryPath = Path.Combine(ProgramDataPath, "logs"); _logDirectoryPath = Path.Combine(ProgramDataPath, "logs");
if (!Directory.Exists(_logDirectoryPath)) Directory.CreateDirectory(_logDirectoryPath);
{
Directory.CreateDirectory(_logDirectoryPath);
}
} }
return _logDirectoryPath; return _logDirectoryPath;
} }
@ -219,10 +201,7 @@ namespace MediaBrowser.Common.Implementations
if (_configurationDirectoryPath == null) if (_configurationDirectoryPath == null)
{ {
_configurationDirectoryPath = Path.Combine(ProgramDataPath, "config"); _configurationDirectoryPath = Path.Combine(ProgramDataPath, "config");
if (!Directory.Exists(_configurationDirectoryPath)) Directory.CreateDirectory(_configurationDirectoryPath);
{
Directory.CreateDirectory(_configurationDirectoryPath);
}
} }
return _configurationDirectoryPath; return _configurationDirectoryPath;
} }
@ -256,10 +235,7 @@ namespace MediaBrowser.Common.Implementations
{ {
_cachePath = Path.Combine(ProgramDataPath, "cache"); _cachePath = Path.Combine(ProgramDataPath, "cache");
if (!Directory.Exists(_cachePath)) Directory.CreateDirectory(_cachePath);
{
Directory.CreateDirectory(_cachePath);
}
} }
return _cachePath; return _cachePath;
@ -282,10 +258,7 @@ namespace MediaBrowser.Common.Implementations
{ {
_tempDirectory = Path.Combine(CachePath, "temp"); _tempDirectory = Path.Combine(CachePath, "temp");
if (!Directory.Exists(_tempDirectory)) Directory.CreateDirectory(_tempDirectory);
{
Directory.CreateDirectory(_tempDirectory);
}
} }
return _tempDirectory; return _tempDirectory;
@ -318,10 +291,7 @@ namespace MediaBrowser.Common.Implementations
programDataPath = Path.GetFullPath(programDataPath); programDataPath = Path.GetFullPath(programDataPath);
} }
if (!Directory.Exists(programDataPath)) Directory.CreateDirectory(programDataPath);
{
Directory.CreateDirectory(programDataPath);
}
return programDataPath; return programDataPath;
} }

View File

@ -220,10 +220,10 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
{ {
options.ResourcePool.Release(); options.ResourcePool.Release();
} }
throw new HttpException(string.Format("Connection to {0} timed out", options.Url)) { IsTimedOut = true }; throw new HttpException(string.Format("Connection to {0} timed out", options.Url)) { IsTimedOut = true };
} }
_logger.Info("HttpClientManager.Get url: {0}", options.Url); _logger.Info("HttpClientManager.Get url: {0}", options.Url);
try try
@ -512,10 +512,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
if (operationCanceledException != null) if (operationCanceledException != null)
{ {
// Cleanup // Cleanup
if (File.Exists(tempFile)) DeleteTempFile(tempFile);
{
File.Delete(tempFile);
}
return GetCancellationException(options.Url, options.CancellationToken, operationCanceledException); return GetCancellationException(options.Url, options.CancellationToken, operationCanceledException);
} }
@ -525,10 +522,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
var httpRequestException = ex as HttpRequestException; var httpRequestException = ex as HttpRequestException;
// Cleanup // Cleanup
if (File.Exists(tempFile)) DeleteTempFile(tempFile);
{
File.Delete(tempFile);
}
if (httpRequestException != null) if (httpRequestException != null)
{ {
@ -538,6 +532,18 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
return ex; return ex;
} }
private void DeleteTempFile(string file)
{
try
{
File.Delete(file);
}
catch (IOException)
{
// Might not have been created at all. No need to worry.
}
}
/// <summary> /// <summary>
/// Validates the params. /// Validates the params.
/// </summary> /// </summary>

View File

@ -431,7 +431,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
{ {
var path = Path.Combine(ApplicationPaths.ConfigurationDirectoryPath, "ScheduledTasks"); var path = Path.Combine(ApplicationPaths.ConfigurationDirectoryPath, "ScheduledTasks");
if (create && !Directory.Exists(path)) if (create)
{ {
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
} }
@ -448,7 +448,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
{ {
var path = Path.Combine(ApplicationPaths.DataPath, "ScheduledTasks"); var path = Path.Combine(ApplicationPaths.DataPath, "ScheduledTasks");
if (create && !Directory.Exists(path)) if (create)
{ {
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
} }
@ -507,10 +507,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
var parentPath = Path.GetDirectoryName(path); var parentPath = Path.GetDirectoryName(path);
if (!Directory.Exists(parentPath)) Directory.CreateDirectory(parentPath);
{
Directory.CreateDirectory(parentPath);
}
JsonSerializer.SerializeToFile(triggers.Select(ScheduledTaskHelpers.GetTriggerInfo), path); JsonSerializer.SerializeToFile(triggers.Select(ScheduledTaskHelpers.GetTriggerInfo), path);
} }

View File

@ -234,10 +234,7 @@ namespace MediaBrowser.Common.Plugins
// We can always make this configurable if/when needed // We can always make this configurable if/when needed
_dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(ConfigurationFileName)); _dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(ConfigurationFileName));
if (!Directory.Exists(_dataFolderPath)) Directory.CreateDirectory(_dataFolderPath);
{
Directory.CreateDirectory(_dataFolderPath);
}
} }
return _dataFolderPath; return _dataFolderPath;

View File

@ -30,10 +30,7 @@ namespace MediaBrowser.Controller.Entities
{ {
var path = Configuration.UseCustomLibrary ? GetRootFolderPath(Name) : ConfigurationManager.ApplicationPaths.DefaultUserViewsPath; var path = Configuration.UseCustomLibrary ? GetRootFolderPath(Name) : ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
{
Directory.CreateDirectory(path);
}
return path; return path;
} }
@ -256,10 +253,7 @@ namespace MediaBrowser.Controller.Entities
{ {
_configurationDirectoryPath = GetConfigurationDirectoryPath(Name); _configurationDirectoryPath = GetConfigurationDirectoryPath(Name);
if (!Directory.Exists(_configurationDirectoryPath)) Directory.CreateDirectory(_configurationDirectoryPath);
{
Directory.CreateDirectory(_configurationDirectoryPath);
}
} }
return _configurationDirectoryPath; return _configurationDirectoryPath;

View File

@ -205,10 +205,7 @@ namespace MediaBrowser.Controller.IO
} }
// Check if the target directory exists, if not, create it. // Check if the target directory exists, if not, create it.
if (!Directory.Exists(target)) Directory.CreateDirectory(target);
{
Directory.CreateDirectory(target);
}
foreach (var file in Directory.EnumerateFiles(source)) foreach (var file in Directory.EnumerateFiles(source))
{ {

View File

@ -159,10 +159,7 @@ namespace MediaBrowser.Controller.MediaInfo
{ {
var parentPath = Path.GetDirectoryName(path); var parentPath = Path.GetDirectoryName(path);
if (!Directory.Exists(parentPath)) Directory.CreateDirectory(parentPath);
{
Directory.CreateDirectory(parentPath);
}
await _encoder.ExtractImage(inputPath, type, video.Video3DFormat, time, path, cancellationToken).ConfigureAwait(false); await _encoder.ExtractImage(inputPath, type, video.Video3DFormat, time, path, cancellationToken).ConfigureAwait(false);
chapter.ImagePath = path; chapter.ImagePath = path;

View File

@ -233,16 +233,6 @@ namespace MediaBrowser.Controller.Providers
throw new ArgumentNullException("providerInfo"); throw new ArgumentNullException("providerInfo");
} }
if (CompareDate(item) > providerInfo.LastRefreshed)
{
return true;
}
if (RefreshOnFileSystemStampChange && item.LocationType == LocationType.FileSystem && HasFileSystemStampChanged(item, providerInfo))
{
return true;
}
if (RefreshOnVersionChange && !String.Equals(ProviderVersion, providerInfo.ProviderVersion)) if (RefreshOnVersionChange && !String.Equals(ProviderVersion, providerInfo.ProviderVersion))
{ {
return true; return true;
@ -258,9 +248,30 @@ namespace MediaBrowser.Controller.Providers
return true; return true;
} }
if (NeedsRefreshBasedOnCompareDate(item, providerInfo))
{
return true;
}
if (RefreshOnFileSystemStampChange && item.LocationType == LocationType.FileSystem && HasFileSystemStampChanged(item, providerInfo))
{
return true;
}
return false; return false;
} }
/// <summary>
/// Needses the refresh based on compare date.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="providerInfo">The provider info.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
protected virtual bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
{
return CompareDate(item) > providerInfo.LastRefreshed;
}
/// <summary> /// <summary>
/// Determines if the item's file system stamp has changed from the last time the provider refreshed /// Determines if the item's file system stamp has changed from the last time the provider refreshed
/// </summary> /// </summary>

View File

@ -1,5 +1,6 @@
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
@ -42,16 +43,17 @@ namespace MediaBrowser.Providers
get { return MetadataProviderPriority.First; } get { return MetadataProviderPriority.First; }
} }
/// <summary> private const string XmlFileName = "folder.xml";
/// Override this to return the date that should be compared to the last refresh date protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
/// to determine if this provider should be re-fetched.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>DateTime.</returns>
protected override DateTime CompareDate(BaseItem item)
{ {
var entry = item.MetaLocation != null ? item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "folder.xml")) : null; var xml = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));
return entry != null ? entry.LastWriteTimeUtc : DateTime.MinValue;
if (xml == null)
{
return false;
}
return FileSystem.GetLastWriteTimeUtc(xml, Logger) > providerInfo.LastRefreshed;
} }
/// <summary> /// <summary>
@ -76,7 +78,7 @@ namespace MediaBrowser.Providers
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "folder.xml")); var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));
if (metadataFile != null) if (metadataFile != null)
{ {

View File

@ -7,6 +7,7 @@ using System;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Providers.Savers;
namespace MediaBrowser.Providers.Games namespace MediaBrowser.Providers.Games
{ {
@ -33,10 +34,18 @@ namespace MediaBrowser.Providers.Games
return item is Game; return item is Game;
} }
protected override DateTime CompareDate(BaseItem item) protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
{ {
var xml = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "game.xml")); var savePath = GameXmlSaver.GetGameSavePath(item);
return xml != null ? FileSystem.GetLastWriteTimeUtc(xml, Logger) : DateTime.MinValue;
var xml = item.ResolveArgs.GetMetaFileByPath(savePath) ?? new FileInfo(savePath);
if (!xml.Exists)
{
return false;
}
return FileSystem.GetLastWriteTimeUtc(xml, Logger) > providerInfo.LastRefreshed;
} }
/// <summary> /// <summary>
@ -61,21 +70,17 @@ namespace MediaBrowser.Providers.Games
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var metaFile = Path.Combine(game.MetaLocation, "game.xml"); var metaFile = GameXmlSaver.GetGameSavePath(game);
if (File.Exists(metaFile)) await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
try
{ {
await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false); new BaseItemXmlParser<Game>(Logger).Fetch(game, metaFile, cancellationToken);
}
try finally
{ {
new BaseItemXmlParser<Game>(Logger).Fetch(game, metaFile, cancellationToken); XmlParsingResourcePool.Release();
}
finally
{
XmlParsingResourcePool.Release();
}
} }
SetLastRefreshed(game, DateTime.UtcNow); SetLastRefreshed(game, DateTime.UtcNow);

View File

@ -1,5 +1,6 @@
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
@ -39,16 +40,17 @@ namespace MediaBrowser.Providers.Games
get { return MetadataProviderPriority.First; } get { return MetadataProviderPriority.First; }
} }
/// <summary> private const string XmlFileName = "gamesystem.xml";
/// Override this to return the date that should be compared to the last refresh date protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
/// to determine if this provider should be re-fetched.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>DateTime.</returns>
protected override DateTime CompareDate(BaseItem item)
{ {
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "gamesystem.xml")); var xml = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));
return entry != null ? entry.LastWriteTimeUtc : DateTime.MinValue;
if (xml == null)
{
return false;
}
return FileSystem.GetLastWriteTimeUtc(xml, Logger) > providerInfo.LastRefreshed;
} }
/// <summary> /// <summary>
@ -73,7 +75,7 @@ namespace MediaBrowser.Providers.Games
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "gamesystem.xml")); var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));
if (metadataFile != null) if (metadataFile != null)
{ {

View File

@ -174,10 +174,7 @@ namespace MediaBrowser.Providers.MediaInfo
{ {
var parentPath = Path.GetDirectoryName(path); var parentPath = Path.GetDirectoryName(path);
if (!Directory.Exists(parentPath)) Directory.CreateDirectory(parentPath);
{
Directory.CreateDirectory(parentPath);
}
await _mediaEncoder.ExtractImage(new[] { item.Path }, InputType.AudioFile, null, null, path, cancellationToken).ConfigureAwait(false); await _mediaEncoder.ExtractImage(new[] { item.Path }, InputType.AudioFile, null, null, path, cancellationToken).ConfigureAwait(false);
} }

View File

@ -222,10 +222,7 @@ namespace MediaBrowser.Providers.MediaInfo
{ {
var parentPath = Path.GetDirectoryName(path); var parentPath = Path.GetDirectoryName(path);
if (!Directory.Exists(parentPath)) Directory.CreateDirectory(parentPath);
{
Directory.CreateDirectory(parentPath);
}
await ExtractImageInternal(item, path, cancellationToken).ConfigureAwait(false); await ExtractImageInternal(item, path, cancellationToken).ConfigureAwait(false);
} }

View File

@ -1,6 +1,7 @@
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
@ -43,16 +44,17 @@ namespace MediaBrowser.Providers.Movies
get { return MetadataProviderPriority.First; } get { return MetadataProviderPriority.First; }
} }
/// <summary> private const string XmlFileName = "collection.xml";
/// Override this to return the date that should be compared to the last refresh date protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
/// to determine if this provider should be re-fetched.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>DateTime.</returns>
protected override DateTime CompareDate(BaseItem item)
{ {
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "collection.xml")); var xml = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));
return entry != null ? entry.LastWriteTimeUtc : DateTime.MinValue;
if (xml == null)
{
return false;
}
return FileSystem.GetLastWriteTimeUtc(xml, Logger) > providerInfo.LastRefreshed;
} }
/// <summary> /// <summary>
@ -77,7 +79,7 @@ namespace MediaBrowser.Providers.Movies
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "collection.xml")); var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));
if (metadataFile != null) if (metadataFile != null)
{ {

View File

@ -168,14 +168,21 @@ namespace MediaBrowser.Providers.Movies
// Process images // Process images
var path = GetMovieDataPath(ConfigurationManager.ApplicationPaths, id); var path = GetMovieDataPath(ConfigurationManager.ApplicationPaths, id);
var files = new DirectoryInfo(path) try
.EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly)
.Select(i => i.LastWriteTimeUtc)
.ToList();
if (files.Count > 0)
{ {
return files.Max(); var files = new DirectoryInfo(path)
.EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly)
.Select(i => i.LastWriteTimeUtc)
.ToList();
if (files.Count > 0)
{
return files.Max();
}
}
catch (DirectoryNotFoundException)
{
// Don't blow up
} }
} }
@ -192,11 +199,6 @@ namespace MediaBrowser.Providers.Movies
{ {
var dataPath = Path.Combine(GetMoviesDataPath(appPaths), tmdbId); var dataPath = Path.Combine(GetMoviesDataPath(appPaths), tmdbId);
if (!Directory.Exists(dataPath))
{
Directory.CreateDirectory(dataPath);
}
return dataPath; return dataPath;
} }
@ -209,11 +211,6 @@ namespace MediaBrowser.Providers.Movies
{ {
var dataPath = Path.Combine(appPaths.DataPath, "fanart-movies"); var dataPath = Path.Combine(appPaths.DataPath, "fanart-movies");
if (!Directory.Exists(dataPath))
{
Directory.CreateDirectory(dataPath);
}
return dataPath; return dataPath;
} }

View File

@ -59,6 +59,8 @@ namespace MediaBrowser.Providers.Movies
var path = FanArtMovieProvider.GetMoviesDataPath(_config.CommonApplicationPaths); var path = FanArtMovieProvider.GetMoviesDataPath(_config.CommonApplicationPaths);
Directory.CreateDirectory(path);
var timestampFile = Path.Combine(path, "time.txt"); var timestampFile = Path.Combine(path, "time.txt");
var timestampFileInfo = new FileInfo(timestampFile); var timestampFileInfo = new FileInfo(timestampFile);
@ -146,10 +148,7 @@ namespace MediaBrowser.Providers.Movies
movieDataPath = Path.Combine(movieDataPath, tmdbId); movieDataPath = Path.Combine(movieDataPath, tmdbId);
if (!Directory.Exists(movieDataPath)) Directory.CreateDirectory(movieDataPath);
{
Directory.CreateDirectory(movieDataPath);
}
return FanArtMovieProvider.Current.DownloadMovieXml(movieDataPath, tmdbId, cancellationToken); return FanArtMovieProvider.Current.DownloadMovieXml(movieDataPath, tmdbId, cancellationToken);
} }

View File

@ -15,6 +15,7 @@ using System.Net;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Providers.Savers;
namespace MediaBrowser.Providers.Movies namespace MediaBrowser.Providers.Movies
{ {
@ -233,9 +234,15 @@ namespace MediaBrowser.Providers.Movies
return item.LocationType == LocationType.FileSystem && item.ResolveArgs.ContainsMetaFileByName("collection.xml"); return item.LocationType == LocationType.FileSystem && item.ResolveArgs.ContainsMetaFileByName("collection.xml");
} }
var xmlFileName = MovieProviderFromXml.GetXmlFilename(item); var path = MovieXmlSaver.GetMovieSavePath(item);
return item.LocationType == LocationType.FileSystem && item.ResolveArgs.ContainsMetaFileByName(xmlFileName); if (item.LocationType == LocationType.FileSystem)
{
// If mixed with multiple movies in one folder, resolve args won't have the file system children
return item.ResolveArgs.ContainsMetaFileByName(Path.GetFileName(path)) || File.Exists(path);
}
return false;
} }
/// <summary> /// <summary>

View File

@ -1,9 +1,11 @@
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Providers.Savers;
using System; using System;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
@ -52,23 +54,18 @@ namespace MediaBrowser.Providers.Movies
get { return MetadataProviderPriority.First; } get { return MetadataProviderPriority.First; }
} }
internal static string GetXmlFilename(BaseItem item) protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
{ {
const string filename = "movie.xml"; var savePath = MovieXmlSaver.GetMovieSavePath(item);
return Path.Combine(item.MetaLocation, filename); var xml = item.ResolveArgs.GetMetaFileByPath(savePath) ?? new FileInfo(savePath);
}
/// <summary> if (!xml.Exists)
/// Override this to return the date that should be compared to the last refresh date {
/// to determine if this provider should be re-fetched. return false;
/// </summary> }
/// <param name="item">The item.</param>
/// <returns>DateTime.</returns> return FileSystem.GetLastWriteTimeUtc(xml, Logger) > providerInfo.LastRefreshed;
protected override DateTime CompareDate(BaseItem item)
{
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, GetXmlFilename(item)));
return entry != null ? entry.LastWriteTimeUtc : DateTime.MinValue;
} }
/// <summary> /// <summary>
@ -93,30 +90,24 @@ namespace MediaBrowser.Providers.Movies
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, GetXmlFilename(item))); var path = MovieXmlSaver.GetMovieSavePath(item);
if (metadataFile != null) await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
try
{ {
var path = metadataFile.FullName; var video = (Video)item;
await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false); await new MovieXmlParser(Logger, _itemRepo).FetchAsync(video, path, cancellationToken).ConfigureAwait(false);
}
try finally
{ {
var video = (Video) item; XmlParsingResourcePool.Release();
await new MovieXmlParser(Logger, _itemRepo).FetchAsync(video, path, cancellationToken).ConfigureAwait(false);
}
finally
{
XmlParsingResourcePool.Release();
}
SetLastRefreshed(item, DateTime.UtcNow);
return true;
} }
return false; SetLastRefreshed(item, DateTime.UtcNow);
return true;
} }
} }
} }

View File

@ -1,5 +1,6 @@
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using System; using System;
@ -38,16 +39,17 @@ namespace MediaBrowser.Providers.Movies
get { return MetadataProviderPriority.Second; } get { return MetadataProviderPriority.Second; }
} }
/// <summary> private const string XmlFileName = "person.xml";
/// Override this to return the date that should be compared to the last refresh date protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
/// to determine if this provider should be re-fetched.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>DateTime.</returns>
protected override DateTime CompareDate(BaseItem item)
{ {
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "person.xml")); var xml = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));
return entry != null ? entry.LastWriteTimeUtc : DateTime.MinValue;
if (xml == null)
{
return false;
}
return FileSystem.GetLastWriteTimeUtc(xml, Logger) > providerInfo.LastRefreshed;
} }
/// <summary> /// <summary>
@ -72,7 +74,7 @@ namespace MediaBrowser.Providers.Movies
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "person.xml")); var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));
if (metadataFile != null) if (metadataFile != null)
{ {

View File

@ -1,6 +1,7 @@
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
@ -40,16 +41,17 @@ namespace MediaBrowser.Providers.Music
get { return MetadataProviderPriority.First; } get { return MetadataProviderPriority.First; }
} }
/// <summary> private const string XmlFileName = "artist.xml";
/// Override this to return the date that should be compared to the last refresh date protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
/// to determine if this provider should be re-fetched.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>DateTime.</returns>
protected override DateTime CompareDate(BaseItem item)
{ {
var entry = item.MetaLocation != null ? item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "artist.xml")) : null; var xml = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));
return entry != null ? entry.LastWriteTimeUtc : DateTime.MinValue;
if (xml == null)
{
return false;
}
return FileSystem.GetLastWriteTimeUtc(xml, Logger) > providerInfo.LastRefreshed;
} }
/// <summary> /// <summary>
@ -74,7 +76,7 @@ namespace MediaBrowser.Providers.Music
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "artist.xml")); var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));
if (metadataFile != null) if (metadataFile != null)
{ {

View File

@ -163,14 +163,21 @@ namespace MediaBrowser.Providers.Music
// Process images // Process images
var path = GetArtistDataPath(ConfigurationManager.ApplicationPaths, musicBrainzId); var path = GetArtistDataPath(ConfigurationManager.ApplicationPaths, musicBrainzId);
var files = new DirectoryInfo(path) try
.EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly)
.Select(i => i.LastWriteTimeUtc)
.ToList();
if (files.Count > 0)
{ {
return files.Max(); var files = new DirectoryInfo(path)
.EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly)
.Select(i => i.LastWriteTimeUtc)
.ToList();
if (files.Count > 0)
{
return files.Max();
}
}
catch (DirectoryNotFoundException)
{
} }
} }
@ -192,11 +199,6 @@ namespace MediaBrowser.Providers.Music
{ {
var seriesDataPath = Path.Combine(GetArtistDataPath(appPaths), musicBrainzArtistId); var seriesDataPath = Path.Combine(GetArtistDataPath(appPaths), musicBrainzArtistId);
if (!Directory.Exists(seriesDataPath))
{
Directory.CreateDirectory(seriesDataPath);
}
return seriesDataPath; return seriesDataPath;
} }
@ -209,11 +211,6 @@ namespace MediaBrowser.Providers.Music
{ {
var dataPath = Path.Combine(appPaths.DataPath, "fanart-music"); var dataPath = Path.Combine(appPaths.DataPath, "fanart-music");
if (!Directory.Exists(dataPath))
{
Directory.CreateDirectory(dataPath);
}
return dataPath; return dataPath;
} }

View File

@ -58,6 +58,8 @@ namespace MediaBrowser.Providers.Music
var path = FanArtArtistProvider.GetArtistDataPath(_config.CommonApplicationPaths); var path = FanArtArtistProvider.GetArtistDataPath(_config.CommonApplicationPaths);
Directory.CreateDirectory(path);
var timestampFile = Path.Combine(path, "time.txt"); var timestampFile = Path.Combine(path, "time.txt");
var timestampFileInfo = new FileInfo(timestampFile); var timestampFileInfo = new FileInfo(timestampFile);
@ -167,10 +169,7 @@ namespace MediaBrowser.Providers.Music
artistsDataPath = Path.Combine(artistsDataPath, musicBrainzId); artistsDataPath = Path.Combine(artistsDataPath, musicBrainzId);
if (!Directory.Exists(artistsDataPath)) Directory.CreateDirectory(artistsDataPath);
{
Directory.CreateDirectory(artistsDataPath);
}
return FanArtArtistProvider.Current.DownloadArtistXml(artistsDataPath, musicBrainzId, cancellationToken); return FanArtArtistProvider.Current.DownloadArtistXml(artistsDataPath, musicBrainzId, cancellationToken);
} }

View File

@ -1,9 +1,9 @@
using System.Collections.Generic; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Providers.Movies; using MediaBrowser.Providers.Movies;
using System; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Security; using System.Security;
@ -88,6 +88,16 @@ namespace MediaBrowser.Providers.Savers
public string GetSavePath(BaseItem item) public string GetSavePath(BaseItem item)
{ {
return GetGameSavePath(item);
}
public static string GetGameSavePath(BaseItem item)
{
if (item.IsInMixedFolder)
{
return Path.ChangeExtension(item.Path, ".xml");
}
return Path.Combine(item.MetaLocation, "game.xml"); return Path.Combine(item.MetaLocation, "game.xml");
} }
} }

View File

@ -1,11 +1,11 @@
using System.Collections.Generic; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Configuration;
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.Controller.Persistence; using MediaBrowser.Controller.Persistence;
using MediaBrowser.Providers.Movies; using MediaBrowser.Providers.Movies;
using System; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Security; using System.Security;
@ -117,13 +117,25 @@ namespace MediaBrowser.Providers.Savers
} }
public string GetSavePath(BaseItem item) public string GetSavePath(BaseItem item)
{
return GetMovieSavePath(item);
}
public static string GetMovieSavePath(BaseItem item)
{ {
if (item.IsInMixedFolder) if (item.IsInMixedFolder)
{ {
return Path.ChangeExtension(item.Path, ".xml"); return Path.ChangeExtension(item.Path, ".xml");
} }
var filename = MovieProviderFromXml.GetXmlFilename(item); var filename = GetXmlFilename(item);
return Path.Combine(item.MetaLocation, filename);
}
private static string GetXmlFilename(BaseItem item)
{
const string filename = "movie.xml";
return Path.Combine(item.MetaLocation, filename); return Path.Combine(item.MetaLocation, filename);
} }

View File

@ -98,10 +98,7 @@ namespace MediaBrowser.Providers.Savers
var parentPath = Path.GetDirectoryName(path); var parentPath = Path.GetDirectoryName(path);
if (!Directory.Exists(parentPath)) Directory.CreateDirectory(parentPath);
{
Directory.CreateDirectory(parentPath);
}
var wasHidden = false; var wasHidden = false;

View File

@ -90,7 +90,7 @@ namespace MediaBrowser.Providers.TV
var parent = item.ResolveArgs.Parent; var parent = item.ResolveArgs.Parent;
ValidateImage(episode, item.MetaLocation); ValidateImage(episode);
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -106,7 +106,7 @@ namespace MediaBrowser.Providers.TV
/// <param name="episode">The episode.</param> /// <param name="episode">The episode.</param>
/// <param name="metadataFolderPath">The metadata folder path.</param> /// <param name="metadataFolderPath">The metadata folder path.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
private void ValidateImage(Episode episode, string metadataFolderPath) private void ValidateImage(Episode episode)
{ {
var path = episode.PrimaryImagePath; var path = episode.PrimaryImagePath;

View File

@ -1,6 +1,7 @@
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
@ -59,12 +60,12 @@ namespace MediaBrowser.Providers.TV
} }
/// <summary> /// <summary>
/// Override this to return the date that should be compared to the last refresh date /// Needses the refresh based on compare date.
/// to determine if this provider should be re-fetched.
/// </summary> /// </summary>
/// <param name="item">The item.</param> /// <param name="item">The item.</param>
/// <returns>DateTime.</returns> /// <param name="providerInfo">The provider info.</param>
protected override DateTime CompareDate(BaseItem item) /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
{ {
var metadataFile = Path.Combine(item.MetaLocation, Path.ChangeExtension(Path.GetFileName(item.Path), ".xml")); var metadataFile = Path.Combine(item.MetaLocation, Path.ChangeExtension(Path.GetFileName(item.Path), ".xml"));
@ -72,10 +73,10 @@ namespace MediaBrowser.Providers.TV
if (file == null) if (file == null)
{ {
return base.CompareDate(item); return false;
} }
return file.LastWriteTimeUtc; return FileSystem.GetLastWriteTimeUtc(file, Logger) > providerInfo.LastRefreshed;
} }
/// <summary> /// <summary>

View File

@ -100,14 +100,21 @@ namespace MediaBrowser.Providers.TV
// Process images // Process images
var path = GetSeriesDataPath(ConfigurationManager.ApplicationPaths, id); var path = GetSeriesDataPath(ConfigurationManager.ApplicationPaths, id);
var files = new DirectoryInfo(path) try
.EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly)
.Select(i => i.LastWriteTimeUtc)
.ToList();
if (files.Count > 0)
{ {
return files.Max(); var files = new DirectoryInfo(path)
.EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly)
.Select(i => i.LastWriteTimeUtc)
.ToList();
if (files.Count > 0)
{
return files.Max();
}
}
catch (DirectoryNotFoundException)
{
// Don't blow up
} }
} }
@ -148,11 +155,6 @@ namespace MediaBrowser.Providers.TV
{ {
var seriesDataPath = Path.Combine(GetSeriesDataPath(appPaths), seriesId); var seriesDataPath = Path.Combine(GetSeriesDataPath(appPaths), seriesId);
if (!Directory.Exists(seriesDataPath))
{
Directory.CreateDirectory(seriesDataPath);
}
return seriesDataPath; return seriesDataPath;
} }
@ -165,11 +167,6 @@ namespace MediaBrowser.Providers.TV
{ {
var dataPath = Path.Combine(appPaths.DataPath, "fanart-tv"); var dataPath = Path.Combine(appPaths.DataPath, "fanart-tv");
if (!Directory.Exists(dataPath))
{
Directory.CreateDirectory(dataPath);
}
return dataPath; return dataPath;
} }

View File

@ -59,6 +59,8 @@ namespace MediaBrowser.Providers.TV
var path = FanArtTvProvider.GetSeriesDataPath(_config.CommonApplicationPaths); var path = FanArtTvProvider.GetSeriesDataPath(_config.CommonApplicationPaths);
Directory.CreateDirectory(path);
var timestampFile = Path.Combine(path, "time.txt"); var timestampFile = Path.Combine(path, "time.txt");
var timestampFileInfo = new FileInfo(timestampFile); var timestampFileInfo = new FileInfo(timestampFile);
@ -161,10 +163,7 @@ namespace MediaBrowser.Providers.TV
seriesDataPath = Path.Combine(seriesDataPath, tvdbId); seriesDataPath = Path.Combine(seriesDataPath, tvdbId);
if (!Directory.Exists(seriesDataPath)) Directory.CreateDirectory(seriesDataPath);
{
Directory.CreateDirectory(seriesDataPath);
}
return FanArtTvProvider.Current.DownloadSeriesXml(seriesDataPath, tvdbId, cancellationToken); return FanArtTvProvider.Current.DownloadSeriesXml(seriesDataPath, tvdbId, cancellationToken);
} }

View File

@ -171,14 +171,21 @@ namespace MediaBrowser.Providers.TV
// Process images // Process images
var path = GetSeriesDataPath(ConfigurationManager.ApplicationPaths, seriesId); var path = GetSeriesDataPath(ConfigurationManager.ApplicationPaths, seriesId);
var files = new DirectoryInfo(path) try
.EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly)
.Select(i => i.LastWriteTimeUtc)
.ToList();
if (files.Count > 0)
{ {
return files.Max(); var files = new DirectoryInfo(path)
.EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly)
.Select(i => i.LastWriteTimeUtc)
.ToList();
if (files.Count > 0)
{
return files.Max();
}
}
catch (DirectoryNotFoundException)
{
// Don't blow up
} }
} }
@ -299,11 +306,6 @@ namespace MediaBrowser.Providers.TV
{ {
var seriesDataPath = Path.Combine(GetSeriesDataPath(appPaths), seriesId); var seriesDataPath = Path.Combine(GetSeriesDataPath(appPaths), seriesId);
if (!Directory.Exists(seriesDataPath))
{
Directory.CreateDirectory(seriesDataPath);
}
return seriesDataPath; return seriesDataPath;
} }
@ -316,11 +318,6 @@ namespace MediaBrowser.Providers.TV
{ {
var dataPath = Path.Combine(appPaths.DataPath, "tvdb"); var dataPath = Path.Combine(appPaths.DataPath, "tvdb");
if (!Directory.Exists(dataPath))
{
Directory.CreateDirectory(dataPath);
}
return dataPath; return dataPath;
} }

View File

@ -1,6 +1,7 @@
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
@ -43,16 +44,17 @@ namespace MediaBrowser.Providers.TV
get { return MetadataProviderPriority.First; } get { return MetadataProviderPriority.First; }
} }
/// <summary> private const string XmlFileName = "season.xml";
/// Override this to return the date that should be compared to the last refresh date protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
/// to determine if this provider should be re-fetched.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>DateTime.</returns>
protected override DateTime CompareDate(BaseItem item)
{ {
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "season.xml")); var xml = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));
return entry != null ? entry.LastWriteTimeUtc : DateTime.MinValue;
if (xml == null)
{
return false;
}
return FileSystem.GetLastWriteTimeUtc(xml, Logger) > providerInfo.LastRefreshed;
} }
/// <summary> /// <summary>
@ -77,7 +79,7 @@ namespace MediaBrowser.Providers.TV
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "season.xml")); var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));
if (metadataFile != null) if (metadataFile != null)
{ {

View File

@ -1,13 +1,14 @@
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using System; using System;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Providers.TV namespace MediaBrowser.Providers.TV
{ {
@ -43,16 +44,17 @@ namespace MediaBrowser.Providers.TV
get { return MetadataProviderPriority.First; } get { return MetadataProviderPriority.First; }
} }
/// <summary> private const string XmlFileName = "series.xml";
/// Override this to return the date that should be compared to the last refresh date protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
/// to determine if this provider should be re-fetched.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>DateTime.</returns>
protected override DateTime CompareDate(BaseItem item)
{ {
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "series.xml")); var xml = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));
return entry != null ? entry.LastWriteTimeUtc : DateTime.MinValue;
if (xml == null)
{
return false;
}
return FileSystem.GetLastWriteTimeUtc(xml, Logger) > providerInfo.LastRefreshed;
} }
/// <summary> /// <summary>
@ -77,7 +79,7 @@ namespace MediaBrowser.Providers.TV
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "series.xml")); var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, XmlFileName));
if (metadataFile != null) if (metadataFile != null)
{ {

View File

@ -71,6 +71,8 @@ namespace MediaBrowser.Providers.TV
var path = RemoteSeriesProvider.GetSeriesDataPath(_config.CommonApplicationPaths); var path = RemoteSeriesProvider.GetSeriesDataPath(_config.CommonApplicationPaths);
Directory.CreateDirectory(path);
var timestampFile = Path.Combine(path, "time.txt"); var timestampFile = Path.Combine(path, "time.txt");
var timestampFileInfo = new FileInfo(timestampFile); var timestampFileInfo = new FileInfo(timestampFile);
@ -295,10 +297,7 @@ namespace MediaBrowser.Providers.TV
seriesDataPath = Path.Combine(seriesDataPath, id); seriesDataPath = Path.Combine(seriesDataPath, id);
if (!Directory.Exists(seriesDataPath)) Directory.CreateDirectory(seriesDataPath);
{
Directory.CreateDirectory(seriesDataPath);
}
return RemoteSeriesProvider.Current.DownloadSeriesZip(id, seriesDataPath, cancellationToken); return RemoteSeriesProvider.Current.DownloadSeriesZip(id, seriesDataPath, cancellationToken);
} }

View File

@ -225,10 +225,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
{ {
var parentPath = Path.GetDirectoryName(cacheFilePath); var parentPath = Path.GetDirectoryName(cacheFilePath);
if (!Directory.Exists(parentPath)) Directory.CreateDirectory(parentPath);
{
Directory.CreateDirectory(parentPath);
}
// Save to the cache location // Save to the cache location
using (var cacheFileStream = new FileStream(cacheFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, FileOptions.Asynchronous)) using (var cacheFileStream = new FileStream(cacheFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, FileOptions.Asynchronous))
@ -374,10 +371,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
{ {
var parentPath = Path.GetDirectoryName(croppedImagePath); var parentPath = Path.GetDirectoryName(croppedImagePath);
if (!Directory.Exists(parentPath)) Directory.CreateDirectory(parentPath);
{
Directory.CreateDirectory(parentPath);
}
using (var outputStream = new FileStream(croppedImagePath, FileMode.Create, FileAccess.Write, FileShare.Read)) using (var outputStream = new FileStream(croppedImagePath, FileMode.Create, FileAccess.Write, FileShare.Read))
{ {
@ -528,10 +522,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
var parentPath = Path.GetDirectoryName(fullCachePath); var parentPath = Path.GetDirectoryName(fullCachePath);
if (!Directory.Exists(parentPath)) Directory.CreateDirectory(parentPath);
{
Directory.CreateDirectory(parentPath);
}
// Update the file system cache // Update the file system cache
File.WriteAllText(fullCachePath, size.Width.ToString(UsCulture) + @"|" + size.Height.ToString(UsCulture)); File.WriteAllText(fullCachePath, size.Width.ToString(UsCulture) + @"|" + size.Height.ToString(UsCulture));
@ -701,10 +692,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
{ {
var parentDirectory = Path.GetDirectoryName(enhancedImagePath); var parentDirectory = Path.GetDirectoryName(enhancedImagePath);
if (!Directory.Exists(parentDirectory)) Directory.CreateDirectory(parentDirectory);
{
Directory.CreateDirectory(parentDirectory);
}
//And then save it in the cache //And then save it in the cache
using (var outputStream = new FileStream(enhancedImagePath, FileMode.Create, FileAccess.Write, FileShare.Read)) using (var outputStream = new FileStream(enhancedImagePath, FileMode.Create, FileAccess.Write, FileShare.Read))

View File

@ -527,16 +527,13 @@ namespace MediaBrowser.Server.Implementations.Library
{ {
try try
{ {
if (f.Exists) var item = ResolvePath(f, parent) as T;
{
var item = ResolvePath(f, parent) as T;
if (item != null) if (item != null)
{
lock (list)
{ {
lock (list) list.Add(item);
{
list.Add(item);
}
} }
} }
} }

View File

@ -48,10 +48,7 @@ namespace MediaBrowser.Server.Implementations.Localization
var localizationPath = LocalizationPath; var localizationPath = LocalizationPath;
if (!Directory.Exists(localizationPath)) Directory.CreateDirectory(localizationPath);
{
Directory.CreateDirectory(localizationPath);
}
var existingFiles = Directory.EnumerateFiles(localizationPath, "ratings-*.txt", SearchOption.TopDirectoryOnly) var existingFiles = Directory.EnumerateFiles(localizationPath, "ratings-*.txt", SearchOption.TopDirectoryOnly)
.Select(Path.GetFileName) .Select(Path.GetFileName)

View File

@ -322,10 +322,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
/// <returns>Task.</returns> /// <returns>Task.</returns>
public Task SaveCriticReviews(Guid itemId, IEnumerable<ItemReview> criticReviews) public Task SaveCriticReviews(Guid itemId, IEnumerable<ItemReview> criticReviews)
{ {
if (!Directory.Exists(_criticReviewsPath)) Directory.CreateDirectory(_criticReviewsPath);
{
Directory.CreateDirectory(_criticReviewsPath);
}
var path = Path.Combine(_criticReviewsPath, itemId + ".json"); var path = Path.Combine(_criticReviewsPath, itemId + ".json");

View File

@ -273,10 +273,7 @@ namespace MediaBrowser.Server.Implementations.Providers
var parentPath = Path.GetDirectoryName(path); var parentPath = Path.GetDirectoryName(path);
if (!Directory.Exists(parentPath)) Directory.CreateDirectory(parentPath);
{
Directory.CreateDirectory(parentPath);
}
return path; return path;
} }

View File

@ -182,10 +182,7 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
var parentPath = Path.GetDirectoryName(failHistoryPath); var parentPath = Path.GetDirectoryName(failHistoryPath);
if (!Directory.Exists(parentPath)) Directory.CreateDirectory(parentPath);
{
Directory.CreateDirectory(parentPath);
}
File.WriteAllText(failHistoryPath, string.Join("|", previouslyFailedImages.ToArray())); File.WriteAllText(failHistoryPath, string.Join("|", previouslyFailedImages.ToArray()));
} }

View File

@ -55,10 +55,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg
Version = Version Version = Version
}; };
if (!Directory.Exists(versionedDirectoryPath)) Directory.CreateDirectory(versionedDirectoryPath);
{
Directory.CreateDirectory(versionedDirectoryPath);
}
var tasks = new List<Task>(); var tasks = new List<Task>();
@ -114,10 +111,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg
var tempFolder = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString()); var tempFolder = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString());
if (!Directory.Exists(tempFolder)) Directory.CreateDirectory(tempFolder);
{
Directory.CreateDirectory(tempFolder);
}
try try
{ {
@ -163,10 +157,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg
{ {
var fontsDirectory = Path.Combine(targetPath, "fonts"); var fontsDirectory = Path.Combine(targetPath, "fonts");
if (!Directory.Exists(fontsDirectory)) Directory.CreateDirectory(fontsDirectory);
{
Directory.CreateDirectory(fontsDirectory);
}
const string fontFilename = "ARIALUNI.TTF"; const string fontFilename = "ARIALUNI.TTF";
@ -291,10 +282,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg
{ {
var path = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg"); var path = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg");
if (create && !Directory.Exists(path)) Directory.CreateDirectory(path);
{
Directory.CreateDirectory(path);
}
return path; return path;
} }