diff options
Diffstat (limited to 'Emby.Server.Implementations/ApplicationHost.cs')
| -rw-r--r-- | Emby.Server.Implementations/ApplicationHost.cs | 86 |
1 files changed, 51 insertions, 35 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 713ece421..57c509923 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -7,7 +7,6 @@ using Emby.Dlna.MediaReceiverRegistrar; using Emby.Dlna.Ssdp; using Emby.Drawing; using Emby.Photos; -using Emby.Server.Core.Cryptography; using Emby.Server.Implementations.Activity; using Emby.Server.Implementations.Archiving; using Emby.Server.Implementations.Channels; @@ -879,7 +878,7 @@ namespace Emby.Server.Implementations // This is only needed for disposal purposes. If removing this, make sure to have the manager handle disposing it RegisterSingleInstance(UserRepository); - var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LogManager.GetLogger("SqliteDisplayPreferencesRepository"), JsonSerializer, ApplicationPaths, MemoryStreamFactory); + var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LogManager.GetLogger("SqliteDisplayPreferencesRepository"), JsonSerializer, ApplicationPaths, MemoryStreamFactory, FileSystemManager); DisplayPreferencesRepository = displayPreferencesRepo; RegisterSingleInstance(DisplayPreferencesRepository); @@ -997,7 +996,7 @@ namespace Emby.Server.Implementations EncodingManager = new EncodingManager(FileSystemManager, Logger, MediaEncoder, ChapterManager, LibraryManager); RegisterSingleInstance(EncodingManager); - var sharingRepo = new SharingRepository(LogManager.GetLogger("SharingRepository"), ApplicationPaths); + var sharingRepo = new SharingRepository(LogManager.GetLogger("SharingRepository"), ApplicationPaths, FileSystemManager); sharingRepo.Initialize(); // This is only needed for disposal purposes. If removing this, make sure to have the manager handle disposing it RegisterSingleInstance<ISharingRepository>(sharingRepo); @@ -1351,7 +1350,7 @@ namespace Emby.Server.Implementations private IActivityRepository GetActivityLogRepository() { - var repo = new ActivityRepository(LogManager.GetLogger("ActivityRepository"), ServerConfigurationManager.ApplicationPaths); + var repo = new ActivityRepository(LogManager.GetLogger("ActivityRepository"), ServerConfigurationManager.ApplicationPaths, FileSystemManager); repo.Initialize(); @@ -1640,23 +1639,23 @@ namespace Emby.Server.Implementations var certPath = Path.Combine(ServerConfigurationManager.ApplicationPaths.ProgramDataPath, "ssl", "cert_" + (certHost + "2").GetMD5().ToString("N") + ".pfx"); var password = "embycert"; - if (generateCertificate) - { - if (!FileSystemManager.FileExists(certPath)) - { - FileSystemManager.CreateDirectory(FileSystemManager.GetDirectoryName(certPath)); - - try - { - CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, password, Logger); - } - catch (Exception ex) - { - Logger.ErrorException("Error creating ssl cert", ex); - return null; - } - } - } + //if (generateCertificate) + //{ + // if (!FileSystemManager.FileExists(certPath)) + // { + // FileSystemManager.CreateDirectory(FileSystemManager.GetDirectoryName(certPath)); + + // try + // { + // CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, password, Logger); + // } + // catch (Exception ex) + // { + // Logger.ErrorException("Error creating ssl cert", ex); + // return null; + // } + // } + //} return new CertificateInfo { @@ -1932,13 +1931,13 @@ namespace Emby.Server.Implementations { get { - return SupportsHttps && ServerConfigurationManager.Configuration.EnableHttps; + return SupportsHttps && (ServerConfigurationManager.Configuration.EnableHttps || ServerConfigurationManager.Configuration.RequireHttps); } } public bool SupportsHttps { - get { return Certificate != null; } + get { return Certificate != null || ServerConfigurationManager.Configuration.IsBehindProxy; } } public async Task<string> GetLocalApiUrl() @@ -2208,22 +2207,39 @@ namespace Emby.Server.Implementations { var updateLevel = SystemUpdateLevel; var cacheLength = updateLevel == PackageVersionClass.Release ? - TimeSpan.FromHours(4) : + TimeSpan.FromHours(12) : TimeSpan.FromMinutes(5); - var result = await new GithubUpdater(HttpClient, JsonSerializer).CheckForUpdateResult("MediaBrowser", - "Emby", - ApplicationVersion, - updateLevel, - ReleaseAssetFilename, - "MBServer", - UpdateTargetFileName, - cacheLength, - cancellationToken).ConfigureAwait(false); + try + { + var result = await new GithubUpdater(HttpClient, JsonSerializer).CheckForUpdateResult("MediaBrowser", + "Emby", + ApplicationVersion, + updateLevel, + ReleaseAssetFilename, + "MBServer", + UpdateTargetFileName, + cacheLength, + cancellationToken).ConfigureAwait(false); + + HasUpdateAvailable = result.IsUpdateAvailable; - HasUpdateAvailable = result.IsUpdateAvailable; + return result; + } + catch (HttpException ex) + { + // users are overreacting to this occasionally failing + if (ex.StatusCode.HasValue && ex.StatusCode.Value == HttpStatusCode.Forbidden) + { + HasUpdateAvailable = false; + return new CheckForUpdateResult + { + IsUpdateAvailable = false + }; + } - return result; + throw; + } } protected virtual string UpdateTargetFileName |
