From a447fd291aef2088d890571e80e4d498fc4498d2 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 21 Dec 2016 23:47:59 -0500 Subject: update osx detection --- Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Emby.Common.Implementations') diff --git a/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs b/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs index 6cc4626ea..dcc974413 100644 --- a/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs +++ b/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs @@ -10,11 +10,17 @@ namespace Emby.Common.Implementations.EnvironmentInfo public class EnvironmentInfo : IEnvironmentInfo { public MediaBrowser.Model.System.Architecture? CustomArchitecture { get; set; } + public MediaBrowser.Model.System.OperatingSystem? CustomOperatingSystem { get; set; } public MediaBrowser.Model.System.OperatingSystem OperatingSystem { get { + if (CustomOperatingSystem.HasValue) + { + return CustomOperatingSystem.Value; + } + #if NET46 switch (Environment.OSVersion.Platform) { -- cgit v1.2.3 From 11e33cd00c8a474201926b8755fdd6254375432b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Dec 2016 10:57:45 -0500 Subject: add scheduled task error handling --- .../ScheduledTasks/ScheduledTaskWorker.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'Emby.Common.Implementations') diff --git a/Emby.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index cbc7c7c2d..de528a94f 100644 --- a/Emby.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/Emby.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -282,9 +282,12 @@ namespace Emby.Common.Implementations.ScheduledTasks throw new ArgumentNullException("value"); } - SaveTriggers(value); + // This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectly + var triggerList = value.Where(i => i != null).ToArray(); - InternalTriggers = value.Select(i => new Tuple(i, GetTrigger(i))).ToArray(); + SaveTriggers(triggerList); + + InternalTriggers = triggerList.Select(i => new Tuple(i, GetTrigger(i))).ToArray(); } } @@ -535,7 +538,8 @@ namespace Emby.Common.Implementations.ScheduledTasks /// IEnumerable{BaseTaskTrigger}. private Tuple[] LoadTriggers() { - var settings = LoadTriggerSettings(); + // This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectly + var settings = LoadTriggerSettings().Where(i => i != null).ToArray(); return settings.Select(i => new Tuple(i, GetTrigger(i))).ToArray(); } @@ -544,8 +548,12 @@ namespace Emby.Common.Implementations.ScheduledTasks { try { - return JsonSerializer.DeserializeFromFile>(GetConfigurationFilePath()) - .ToArray(); + var list = JsonSerializer.DeserializeFromFile>(GetConfigurationFilePath()); + + if (list != null) + { + return list.ToArray(); + } } catch (FileNotFoundException) { @@ -555,8 +563,8 @@ namespace Emby.Common.Implementations.ScheduledTasks catch (DirectoryNotFoundException) { // File doesn't exist. No biggie. Return defaults. - return ScheduledTask.GetDefaultTriggers().ToArray(); } + return ScheduledTask.GetDefaultTriggers().ToArray(); } /// -- cgit v1.2.3 From 325066f7edb52481e93be3b3d90db45645d6924b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 26 Dec 2016 12:38:12 -0500 Subject: update logging --- Emby.Common.Implementations/BaseApplicationHost.cs | 2 ++ Emby.Server.Core/ApplicationHost.cs | 5 ++++- .../EntryPoints/AutomaticRestartEntryPoint.cs | 4 +++- Emby.Server.Implementations/HttpServer/HttpListenerHost.cs | 11 +++++++++-- Emby.Server.Implementations/HttpServer/IHttpListener.cs | 2 +- .../HttpServer/SocketSharp/WebSocketSharpListener.cs | 4 ++-- MediaBrowser.Providers/TV/MissingEpisodeProvider.cs | 6 ++++++ 7 files changed, 27 insertions(+), 7 deletions(-) (limited to 'Emby.Common.Implementations') diff --git a/Emby.Common.Implementations/BaseApplicationHost.cs b/Emby.Common.Implementations/BaseApplicationHost.cs index 02d7cb31f..9c9e14ec6 100644 --- a/Emby.Common.Implementations/BaseApplicationHost.cs +++ b/Emby.Common.Implementations/BaseApplicationHost.cs @@ -795,6 +795,8 @@ return null; /// public void NotifyPendingRestart() { + Logger.Info("App needs to be restarted."); + var changed = !HasPendingRestart; HasPendingRestart = true; diff --git a/Emby.Server.Core/ApplicationHost.cs b/Emby.Server.Core/ApplicationHost.cs index 3590ade40..215ac8492 100644 --- a/Emby.Server.Core/ApplicationHost.cs +++ b/Emby.Server.Core/ApplicationHost.cs @@ -1083,6 +1083,8 @@ namespace Emby.Server.Core if (requiresRestart) { + Logger.Info("App needs to be restarted due to configuration change."); + NotifyPendingRestart(); } } @@ -1204,7 +1206,8 @@ namespace Emby.Server.Core var exclude = new[] { "mbplus.dll", - "mbintros.dll" + "mbintros.dll", + "embytv.dll" }; return !exclude.Contains(filename ?? string.Empty, StringComparer.OrdinalIgnoreCase); diff --git a/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs b/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs index 38708648f..561f5ee12 100644 --- a/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs +++ b/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs @@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.EntryPoints if (_appHost.HasPendingRestart) { - _timer = _timerFactory.Create(TimerCallback, null, TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10)); + _timer = _timerFactory.Create(TimerCallback, null, TimeSpan.FromMinutes(15), TimeSpan.FromMinutes(15)); } } @@ -65,6 +65,8 @@ namespace Emby.Server.Implementations.EntryPoints { DisposeTimer(); + _logger.Info("Automatically restarting the system because it is idle and a restart is required."); + try { _appHost.Restart(); diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index 0e1f5a551..83885ee2e 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -228,11 +228,14 @@ namespace Emby.Server.Implementations.HttpServer } } - private void ErrorHandler(Exception ex, IRequest httpReq) + private void ErrorHandler(Exception ex, IRequest httpReq, bool logException = true) { try { - _logger.ErrorException("Error processing request", ex); + if (logException) + { + _logger.ErrorException("Error processing request", ex); + } var httpRes = httpReq.Response; @@ -529,6 +532,10 @@ namespace Emby.Server.Implementations.HttpServer ErrorHandler(new FileNotFoundException(), httpReq); } } + catch (OperationCanceledException ex) + { + ErrorHandler(ex, httpReq, false); + } catch (Exception ex) { ErrorHandler(ex, httpReq); diff --git a/Emby.Server.Implementations/HttpServer/IHttpListener.cs b/Emby.Server.Implementations/HttpServer/IHttpListener.cs index 9f96a8e49..18df5682d 100644 --- a/Emby.Server.Implementations/HttpServer/IHttpListener.cs +++ b/Emby.Server.Implementations/HttpServer/IHttpListener.cs @@ -12,7 +12,7 @@ namespace Emby.Server.Implementations.HttpServer /// Gets or sets the error handler. /// /// The error handler. - Action ErrorHandler { get; set; } + Action ErrorHandler { get; set; } /// /// Gets or sets the request handler. diff --git a/Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs b/Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs index 4606d0e31..652fc4f83 100644 --- a/Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs +++ b/Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs @@ -44,7 +44,7 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp _httpRequestFactory = httpRequestFactory; } - public Action ErrorHandler { get; set; } + public Action ErrorHandler { get; set; } public Func RequestHandler { get; set; } public Action WebSocketConnecting { get; set; } @@ -102,7 +102,7 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp _logger.ErrorException("Error processing request", ex); httpReq = httpReq ?? GetRequest(context); - ErrorHandler(ex, httpReq); + ErrorHandler(ex, httpReq, true); return Task.FromResult(true); } diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs index 538512557..22e7e753c 100644 --- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs @@ -87,6 +87,12 @@ namespace MediaBrowser.Providers.TV var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); + // Doesn't have required provider id's + if (string.IsNullOrWhiteSpace(seriesDataPath)) + { + return; + } + var episodeFiles = _fileSystem.GetFilePaths(seriesDataPath) .Where(i => string.Equals(Path.GetExtension(i), ".xml", StringComparison.OrdinalIgnoreCase)) .Select(Path.GetFileNameWithoutExtension) -- cgit v1.2.3 From c53ab214c783b471e3701fbc7a2319139c38fa9a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 27 Dec 2016 02:25:51 -0500 Subject: update SwapFiles --- .../IO/ManagedFileSystem.cs | 29 ++-------------------- 1 file changed, 2 insertions(+), 27 deletions(-) (limited to 'Emby.Common.Implementations') diff --git a/Emby.Common.Implementations/IO/ManagedFileSystem.cs b/Emby.Common.Implementations/IO/ManagedFileSystem.cs index 62d285072..78070a5d9 100644 --- a/Emby.Common.Implementations/IO/ManagedFileSystem.cs +++ b/Emby.Common.Implementations/IO/ManagedFileSystem.cs @@ -490,38 +490,13 @@ namespace Emby.Common.Implementations.IO var temp1 = Path.GetTempFileName(); // Copying over will fail against hidden files - RemoveHiddenAttribute(file1); - RemoveHiddenAttribute(file2); + SetHidden(file1, false); + SetHidden(file2, false); CopyFile(file1, temp1, true); CopyFile(file2, file1, true); CopyFile(temp1, file2, true); - - DeleteFile(temp1); - } - - /// - /// Removes the hidden attribute. - /// - /// The path. - private void RemoveHiddenAttribute(string path) - { - if (string.IsNullOrEmpty(path)) - { - throw new ArgumentNullException("path"); - } - - var currentFile = new FileInfo(path); - - // This will fail if the file is hidden - if (currentFile.Exists) - { - if ((currentFile.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) - { - currentFile.Attributes &= ~FileAttributes.Hidden; - } - } } public bool ContainsSubPath(string parentPath, string path) -- cgit v1.2.3