add image saver logging

This commit is contained in:
Luke Pulverenti 2013-11-08 10:35:11 -05:00
parent 1f0fc33a86
commit c9d9c6ff1f
4 changed files with 15 additions and 4 deletions

View File

@ -165,7 +165,8 @@ namespace MediaBrowser.Server.Implementations.Dto
{
var folder = (Folder)item;
dto.ChildCount = folder.GetChildren(user, true).Count();
dto.ChildCount = folder.GetChildren(user, true)
.Count();
if (!(folder is UserRootFolder))
{

View File

@ -67,7 +67,8 @@ namespace MediaBrowser.Server.Implementations.IO
public async void RemoveTempIgnore(string path)
{
// This is an arbitraty amount of time, but delay it because file system writes often trigger events after RemoveTempIgnore has been called.
await Task.Delay(2000).ConfigureAwait(false);
// Seeing long delays in some situations, especially over the network.
await Task.Delay(40000).ConfigureAwait(false);
string val;
_tempIgnoredPaths.TryRemove(path, out val);

View File

@ -13,6 +13,7 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Server.Implementations.Providers
{
@ -37,17 +38,19 @@ namespace MediaBrowser.Server.Implementations.Providers
/// </summary>
private readonly IDirectoryWatchers _directoryWatchers;
private readonly IFileSystem _fileSystem;
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="ImageSaver"/> class.
/// </summary>
/// <param name="config">The config.</param>
/// <param name="directoryWatchers">The directory watchers.</param>
public ImageSaver(IServerConfigurationManager config, IDirectoryWatchers directoryWatchers, IFileSystem fileSystem)
public ImageSaver(IServerConfigurationManager config, IDirectoryWatchers directoryWatchers, IFileSystem fileSystem, ILogger logger)
{
_config = config;
_directoryWatchers = directoryWatchers;
_fileSystem = fileSystem;
_logger = logger;
_remoteImageCache = new FileSystemRepository(config.ApplicationPaths.DownloadedImagesDataPath);
}
@ -170,7 +173,12 @@ namespace MediaBrowser.Server.Implementations.Providers
/// <returns>Task.</returns>
private async Task SaveImageToLocation(Stream source, string path, CancellationToken cancellationToken)
{
_logger.Debug("Saving image to {0}", path);
var parentFolder = Path.GetDirectoryName(path);
_directoryWatchers.TemporarilyIgnore(path);
_directoryWatchers.TemporarilyIgnore(parentFolder);
try
{
@ -196,6 +204,7 @@ namespace MediaBrowser.Server.Implementations.Providers
finally
{
_directoryWatchers.RemoveTempIgnore(path);
_directoryWatchers.RemoveTempIgnore(parentFolder);
}
}

View File

@ -349,7 +349,7 @@ namespace MediaBrowser.Server.Implementations.Providers
/// <returns>Task.</returns>
public Task SaveImage(BaseItem item, Stream source, string mimeType, ImageType type, int? imageIndex, string sourceUrl, CancellationToken cancellationToken)
{
return new ImageSaver(ConfigurationManager, _directoryWatchers, _fileSystem).SaveImage(item, source, mimeType, type, imageIndex, sourceUrl, cancellationToken);
return new ImageSaver(ConfigurationManager, _directoryWatchers, _fileSystem, _logger).SaveImage(item, source, mimeType, type, imageIndex, sourceUrl, cancellationToken);
}
/// <summary>