update realtime monitor

This commit is contained in:
Luke Pulverenti 2017-05-27 03:19:09 -04:00
parent 89ba154522
commit ffb68b0318
8 changed files with 50 additions and 32 deletions

View File

@ -87,8 +87,9 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
private void ProcessContext(HttpListenerContext context) private void ProcessContext(HttpListenerContext context)
{ {
//Task.Factory.StartNew(() => InitTask(context), TaskCreationOptions.DenyChildAttach | TaskCreationOptions.PreferFairness); _logger.Info("thread id {0}", Thread.CurrentThread.ManagedThreadId);
Task.Run(() => InitTask(context, _disposeCancellationToken)); InitTask(context, _disposeCancellationToken);
//Task.Run(() => InitTask(context, _disposeCancellationToken));
} }
private Task InitTask(HttpListenerContext context, CancellationToken cancellationToken) private Task InitTask(HttpListenerContext context, CancellationToken cancellationToken)

View File

@ -180,7 +180,7 @@ namespace Emby.Server.Implementations.IO
try try
{ {
await item.ChangedExternally().ConfigureAwait(false); item.ChangedExternally();
} }
catch (IOException ex) catch (IOException ex)
{ {
@ -282,11 +282,11 @@ namespace Emby.Server.Implementations.IO
return false; return false;
} }
} }
//catch (DirectoryNotFoundException) catch (DirectoryNotFoundException)
//{ {
// // File may have been deleted // File may have been deleted
// return false; return false;
//} }
catch (FileNotFoundException) catch (FileNotFoundException)
{ {
// File may have been deleted // File may have been deleted

View File

@ -66,19 +66,19 @@ namespace Emby.Server.Implementations.Session
return SendMessage(name, new Dictionary<string, string>(), cancellationToken); return SendMessage(name, new Dictionary<string, string>(), cancellationToken);
} }
private async Task SendMessage(string name, private Task SendMessage(string name,
Dictionary<string, string> args, Dictionary<string, string> args,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
var url = PostUrl + "/" + name + ToQueryString(args); var url = PostUrl + "/" + name + ToQueryString(args);
await _httpClient.Post(new HttpRequestOptions return _httpClient.Post(new HttpRequestOptions
{ {
Url = url, Url = url,
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
BufferContent = false BufferContent = false
}).ConfigureAwait(false); });
} }
public Task SendSessionEndedNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken) public Task SendSessionEndedNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken)
@ -159,8 +159,24 @@ namespace Emby.Server.Implementations.Session
public Task SendMessage<T>(string name, T data, CancellationToken cancellationToken) public Task SendMessage<T>(string name, T data, CancellationToken cancellationToken)
{ {
// Not supported or needed right now var url = PostUrl + "/" + name;
return Task.FromResult(true);
var options = new HttpRequestOptions
{
Url = url,
CancellationToken = cancellationToken,
BufferContent = false
};
options.RequestContent = _json.SerializeToString(data);
options.RequestContentType = "application/json";
return _httpClient.Post(new HttpRequestOptions
{
Url = url,
CancellationToken = cancellationToken,
BufferContent = false
});
} }
private string ToQueryString(Dictionary<string, string> nvc) private string ToQueryString(Dictionary<string, string> nvc)

View File

@ -1854,10 +1854,13 @@ namespace MediaBrowser.Controller.Entities
/// Do whatever refreshing is necessary when the filesystem pertaining to this item has changed. /// Do whatever refreshing is necessary when the filesystem pertaining to this item has changed.
/// </summary> /// </summary>
/// <returns>Task.</returns> /// <returns>Task.</returns>
public virtual Task ChangedExternally() public virtual void ChangedExternally()
{ {
ProviderManager.QueueRefresh(Id, new MetadataRefreshOptions(FileSystem), RefreshPriority.High); ProviderManager.QueueRefresh(Id, new MetadataRefreshOptions(FileSystem)
return Task.FromResult(true); {
ValidateChildren = true,
}, RefreshPriority.High);
} }
/// <summary> /// <summary>

View File

@ -1325,19 +1325,6 @@ namespace MediaBrowser.Controller.Entities
return false; return false;
} }
/// <summary>
/// Folders need to validate and refresh
/// </summary>
/// <returns>Task.</returns>
public override async Task ChangedExternally()
{
var progress = new Progress<double>();
await ValidateChildren(progress, CancellationToken.None).ConfigureAwait(false);
await base.ChangedExternally().ConfigureAwait(false);
}
/// <summary> /// <summary>
/// Marks the played. /// Marks the played.
/// </summary> /// </summary>

View File

@ -15,6 +15,7 @@ namespace MediaBrowser.Controller.Providers
public bool ReplaceAllMetadata { get; set; } public bool ReplaceAllMetadata { get; set; }
public bool IsPostRecursiveRefresh { get; set; } public bool IsPostRecursiveRefresh { get; set; }
public bool ValidateChildren { get; set; }
public MetadataRefreshMode MetadataRefreshMode { get; set; } public MetadataRefreshMode MetadataRefreshMode { get; set; }
public RemoteSearchResult SearchResult { get; set; } public RemoteSearchResult SearchResult { get; set; }

View File

@ -872,7 +872,7 @@ namespace MediaBrowser.Providers.Manager
if (!_isProcessingRefreshQueue) if (!_isProcessingRefreshQueue)
{ {
_isProcessingRefreshQueue = true; _isProcessingRefreshQueue = true;
Task.Run(() => StartProcessingRefreshQueue()); Task.Run(StartProcessingRefreshQueue);
} }
} }
} }
@ -897,6 +897,15 @@ namespace MediaBrowser.Providers.Manager
// Try to throttle this a little bit. // Try to throttle this a little bit.
await Task.Delay(100).ConfigureAwait(false); await Task.Delay(100).ConfigureAwait(false);
if (refreshItem.Item2.ValidateChildren)
{
var folder = item as Folder;
if (folder != null)
{
await folder.ValidateChildren(new Progress<double>(), CancellationToken.None).ConfigureAwait(false);
}
}
var artist = item as MusicArtist; var artist = item as MusicArtist;
var task = artist == null var task = artist == null
? RefreshItem(item, refreshItem.Item2, CancellationToken.None) ? RefreshItem(item, refreshItem.Item2, CancellationToken.None)

View File

@ -163,7 +163,7 @@ namespace MediaBrowser.Providers.Subtitles
Provider = provider.Name Provider = provider.Name
}, _logger); }, _logger);
throw; throw;
} }
} }
@ -256,7 +256,8 @@ namespace MediaBrowser.Providers.Subtitles
_monitor.ReportFileSystemChangeComplete(path, false); _monitor.ReportFileSystemChangeComplete(path, false);
} }
return _libraryManager.GetItemById(itemId).ChangedExternally(); _libraryManager.GetItemById(itemId).ChangedExternally();
return Task.FromResult(true);
} }
public Task<SubtitleResponse> GetRemoteSubtitles(string id, CancellationToken cancellationToken) public Task<SubtitleResponse> GetRemoteSubtitles(string id, CancellationToken cancellationToken)