mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 03:26:07 +02:00
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
This commit is contained in:
commit
52a7267864
6 changed files with 92 additions and 30 deletions
|
@ -201,7 +201,7 @@ namespace MediaBrowser.Common.Implementations
|
|||
|
||||
Task.Run(() => ConfigureAutoRunAtStartup());
|
||||
|
||||
ConfigurationManager.ConfigurationUpdated += ConfigurationManager_ConfigurationUpdated;
|
||||
ConfigurationManager.ConfigurationUpdated += OnConfigurationUpdated;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,7 @@ namespace MediaBrowser.Common.Implementations
|
|||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
void ConfigurationManager_ConfigurationUpdated(object sender, EventArgs e)
|
||||
protected virtual void OnConfigurationUpdated(object sender, EventArgs e)
|
||||
{
|
||||
ConfigureAutoRunAtStartup();
|
||||
}
|
||||
|
|
|
@ -410,11 +410,13 @@ namespace MediaBrowser.Server.Implementations.IO
|
|||
return false;
|
||||
}
|
||||
|
||||
FileStream stream = null;
|
||||
|
||||
try
|
||||
{
|
||||
stream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
|
||||
using (new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
|
||||
{
|
||||
//file is not locked
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -424,14 +426,6 @@ namespace MediaBrowser.Server.Implementations.IO
|
|||
//or does not exist (has already been processed)
|
||||
return true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (stream != null)
|
||||
stream.Close();
|
||||
}
|
||||
|
||||
//file is not locked
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -682,6 +682,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
|||
|
||||
throw new ApplicationException(msg);
|
||||
}
|
||||
await SetAssFont(outputPath).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -843,6 +844,36 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
|||
|
||||
throw new ApplicationException(msg);
|
||||
}
|
||||
|
||||
await SetAssFont(outputPath).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the ass font.
|
||||
/// </summary>
|
||||
/// <param name="file">The file.</param>
|
||||
/// <returns>Task.</returns>
|
||||
private async Task SetAssFont(string file)
|
||||
{
|
||||
string text;
|
||||
Encoding encoding;
|
||||
|
||||
using (var reader = new StreamReader(file, detectEncodingFromByteOrderMarks: true))
|
||||
{
|
||||
encoding = reader.CurrentEncoding;
|
||||
|
||||
text = await reader.ReadToEndAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var newText = text.Replace(",Arial,", ",Arial Unicode MS,");
|
||||
|
||||
if (!string.Equals(text, newText))
|
||||
{
|
||||
using (var writer = new StreamWriter(file, false, encoding))
|
||||
{
|
||||
writer.Write(newText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -457,9 +457,9 @@ namespace MediaBrowser.Server.Implementations.Providers
|
|||
{
|
||||
var ms = new MemoryStream();
|
||||
|
||||
using (var input = dataToSave)
|
||||
using (dataToSave)
|
||||
{
|
||||
await input.CopyToAsync(ms).ConfigureAwait(false);
|
||||
await dataToSave.CopyToAsync(ms).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
ms.Position = 0;
|
||||
|
@ -470,9 +470,9 @@ namespace MediaBrowser.Server.Implementations.Providers
|
|||
{
|
||||
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, FileOptions.Asynchronous))
|
||||
{
|
||||
using (var input = dataToSave)
|
||||
using (dataToSave)
|
||||
{
|
||||
await input.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, cancellationToken).ConfigureAwait(false);
|
||||
await dataToSave.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,6 +114,8 @@ namespace MediaBrowser.Server.Implementations.ServerManager
|
|||
_applicationHost = applicationHost;
|
||||
ConfigurationManager = configurationManager;
|
||||
_kernel = kernel;
|
||||
|
||||
ConfigurationManager.ConfigurationUpdated += ConfigurationUpdated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -127,8 +129,6 @@ namespace MediaBrowser.Server.Implementations.ServerManager
|
|||
{
|
||||
ReloadExternalWebSocketServer();
|
||||
}
|
||||
|
||||
ConfigurationManager.ConfigurationUpdated += ConfigurationUpdated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -352,16 +352,6 @@ namespace MediaBrowser.Server.Implementations.ServerManager
|
|||
void ConfigurationUpdated(object sender, EventArgs e)
|
||||
{
|
||||
HttpServer.EnableHttpRequestLogging = ConfigurationManager.Configuration.EnableHttpLevelLogging;
|
||||
|
||||
if (!string.Equals(HttpServer.UrlPrefix, _kernel.HttpServerUrlPrefix, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ReloadHttpServer();
|
||||
}
|
||||
|
||||
if (!SupportsNativeWebSocket && ExternalWebSocketServer != null && ExternalWebSocketServer.Port != ConfigurationManager.Configuration.LegacyWebSocketPortNumber)
|
||||
{
|
||||
ReloadExternalWebSocketServer();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -382,7 +382,8 @@ namespace MediaBrowser.ServerApplication
|
|||
HttpServer.Init(GetExports<IRestfulService>(false));
|
||||
|
||||
ServerManager.AddWebSocketListeners(GetExports<IWebSocketListener>(false));
|
||||
ServerManager.Start();
|
||||
|
||||
StartServer(true);
|
||||
},
|
||||
|
||||
() => LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(), GetExports<IVirtualFolderCreator>(), GetExports<IItemResolver>(), GetExports<IIntroProvider>(), GetExports<IBaseItemComparer>()),
|
||||
|
@ -405,6 +406,52 @@ namespace MediaBrowser.ServerApplication
|
|||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts the server.
|
||||
/// </summary>
|
||||
/// <param name="retryOnFailure">if set to <c>true</c> [retry on failure].</param>
|
||||
private void StartServer(bool retryOnFailure)
|
||||
{
|
||||
try
|
||||
{
|
||||
ServerManager.Start();
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (retryOnFailure)
|
||||
{
|
||||
RegisterServerWithAdministratorAccess();
|
||||
|
||||
StartServer(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when [configuration updated].
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
protected override void OnConfigurationUpdated(object sender, EventArgs e)
|
||||
{
|
||||
base.OnConfigurationUpdated(sender, e);
|
||||
|
||||
if (!string.Equals(HttpServer.UrlPrefix, ServerKernel.HttpServerUrlPrefix, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
NotifyPendingRestart();
|
||||
}
|
||||
|
||||
else if (!ServerManager.SupportsNativeWebSocket && ServerManager.WebSocketPortNumber != ServerConfigurationManager.Configuration.LegacyWebSocketPortNumber)
|
||||
{
|
||||
NotifyPendingRestart();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restarts this instance.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in a new issue