From a2dd2ddd55adc001bf3752dce6d4a95616e5dc4b Mon Sep 17 00:00:00 2001
From: ploughpuff <33969763+ploughpuff@users.noreply.github.com>
Date: Wed, 13 Feb 2019 15:35:14 +0000
Subject: Rewrite rules for determining app paths and use XDG_CONFIG_HOME for
configDir (#781)
Re-write rules for determining dataDir, configDir and logDir. Generally, arguments from command line take precedence, then JELLYFIN env vars, before using XDG names.
Co-Authored-By: ploughpuff <33969763+ploughpuff@users.noreply.github.com>
---
.../AppBase/BaseApplicationPaths.cs | 103 +++++----------------
1 file changed, 21 insertions(+), 82 deletions(-)
(limited to 'Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs')
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
index 701c04f9e..f26cc4f62 100644
--- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
+++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
@@ -1,3 +1,4 @@
+using System;
using System.IO;
using MediaBrowser.Common.Configuration;
@@ -14,50 +15,44 @@ namespace Emby.Server.Implementations.AppBase
///
protected BaseApplicationPaths(
string programDataPath,
- string appFolderPath,
- string logDirectoryPath = null,
- string configurationDirectoryPath = null,
- string cacheDirectoryPath = null)
+ string logDirectoryPath,
+ string configurationDirectoryPath,
+ string cacheDirectoryPath)
{
ProgramDataPath = programDataPath;
- ProgramSystemPath = appFolderPath;
LogDirectoryPath = logDirectoryPath;
ConfigurationDirectoryPath = configurationDirectoryPath;
CachePath = cacheDirectoryPath;
+
+ DataPath = Path.Combine(ProgramDataPath, "data");
}
+ ///
+ /// Gets the path to the program data folder
+ ///
+ /// The program data path.
public string ProgramDataPath { get; private set; }
///
/// Gets the path to the system folder
///
- public string ProgramSystemPath { get; private set; }
+ public string ProgramSystemPath { get; } = AppContext.BaseDirectory;
- ///
- /// The _data directory
- ///
- private string _dataDirectory;
///
/// Gets the folder path to the data directory
///
/// The data directory.
+ private string _dataPath;
public string DataPath
{
- get
- {
- if (_dataDirectory == null)
- {
- _dataDirectory = Path.Combine(ProgramDataPath, "data");
-
- Directory.CreateDirectory(_dataDirectory);
- }
-
- return _dataDirectory;
- }
+ get => _dataPath;
+ private set => _dataPath = Directory.CreateDirectory(value).FullName;
}
- private const string _virtualDataPath = "%AppDataPath%";
- public string VirtualDataPath => _virtualDataPath;
+ ///
+ /// Gets the magic strings used for virtual path manipulation.
+ ///
+ public string VirtualDataPath { get; } = "%AppDataPath%";
///
/// Gets the image cache path.
@@ -83,55 +78,17 @@ namespace Emby.Server.Implementations.AppBase
/// The plugin configurations path.
public string TempUpdatePath => Path.Combine(ProgramDataPath, "updates");
- ///
- /// The _log directory
- ///
- private string _logDirectoryPath;
-
///
/// Gets the path to the log directory
///
/// The log directory path.
- public string LogDirectoryPath
- {
- get
- {
- if (string.IsNullOrEmpty(_logDirectoryPath))
- {
- _logDirectoryPath = Path.Combine(ProgramDataPath, "logs");
-
- Directory.CreateDirectory(_logDirectoryPath);
- }
-
- return _logDirectoryPath;
- }
- set => _logDirectoryPath = value;
- }
-
- ///
- /// The _config directory
- ///
- private string _configurationDirectoryPath;
+ public string LogDirectoryPath { get; private set; }
///
/// Gets the path to the application configuration root directory
///
/// The configuration directory path.
- public string ConfigurationDirectoryPath
- {
- get
- {
- if (string.IsNullOrEmpty(_configurationDirectoryPath))
- {
- _configurationDirectoryPath = Path.Combine(ProgramDataPath, "config");
-
- Directory.CreateDirectory(_configurationDirectoryPath);
- }
-
- return _configurationDirectoryPath;
- }
- set => _configurationDirectoryPath = value;
- }
+ public string ConfigurationDirectoryPath { get; private set; }
///
/// Gets the path to the system configuration file
@@ -139,29 +96,11 @@ namespace Emby.Server.Implementations.AppBase
/// The system configuration file path.
public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml");
- ///
- /// The _cache directory
- ///
- private string _cachePath;
///
/// Gets the folder path to the cache directory
///
/// The cache directory.
- public string CachePath
- {
- get
- {
- if (string.IsNullOrEmpty(_cachePath))
- {
- _cachePath = Path.Combine(ProgramDataPath, "cache");
-
- Directory.CreateDirectory(_cachePath);
- }
-
- return _cachePath;
- }
- set => _cachePath = value;
- }
+ public string CachePath { get; set; }
///
/// Gets the folder path to the temp directory within the cache folder
--
cgit v1.2.3
From 77a5617774eaf20314a40620fcb0b63d4cb17963 Mon Sep 17 00:00:00 2001
From: Bond_009
Date: Wed, 6 Feb 2019 20:53:05 +0100
Subject: Removed remaining self-update code
---
Emby.Notifications/CoreNotificationTypes.cs | 32 ++++------------------
Emby.Notifications/Notifications.cs | 4 +--
.../AppBase/BaseApplicationPaths.cs | 6 ----
Emby.Server.Implementations/ApplicationHost.cs | 22 ---------------
.../Configuration/IApplicationPaths.cs | 6 ----
MediaBrowser.Common/IApplicationHost.cs | 12 --------
MediaBrowser.Model/System/SystemInfo.cs | 6 ----
7 files changed, 8 insertions(+), 80 deletions(-)
(limited to 'Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs')
diff --git a/Emby.Notifications/CoreNotificationTypes.cs b/Emby.Notifications/CoreNotificationTypes.cs
index 8cc14fa01..0f9fc08d9 100644
--- a/Emby.Notifications/CoreNotificationTypes.cs
+++ b/Emby.Notifications/CoreNotificationTypes.cs
@@ -11,101 +11,81 @@ namespace Emby.Notifications
public class CoreNotificationTypes : INotificationTypeFactory
{
private readonly ILocalizationManager _localization;
- private readonly IServerApplicationHost _appHost;
- public CoreNotificationTypes(ILocalizationManager localization, IServerApplicationHost appHost)
+ public CoreNotificationTypes(ILocalizationManager localization)
{
_localization = localization;
- _appHost = appHost;
}
public IEnumerable GetNotificationTypes()
{
- var knownTypes = new List
+ var knownTypes = new NotificationTypeInfo[]
{
new NotificationTypeInfo
{
Type = NotificationType.ApplicationUpdateInstalled.ToString()
},
-
new NotificationTypeInfo
{
Type = NotificationType.InstallationFailed.ToString()
},
-
new NotificationTypeInfo
{
Type = NotificationType.PluginInstalled.ToString()
},
-
new NotificationTypeInfo
{
Type = NotificationType.PluginError.ToString()
},
-
new NotificationTypeInfo
{
Type = NotificationType.PluginUninstalled.ToString()
},
-
new NotificationTypeInfo
{
Type = NotificationType.PluginUpdateInstalled.ToString()
},
-
new NotificationTypeInfo
{
Type = NotificationType.ServerRestartRequired.ToString()
},
-
new NotificationTypeInfo
{
Type = NotificationType.TaskFailed.ToString()
},
-
new NotificationTypeInfo
{
Type = NotificationType.NewLibraryContent.ToString()
},
-
new NotificationTypeInfo
{
Type = NotificationType.AudioPlayback.ToString()
},
-
new NotificationTypeInfo
{
Type = NotificationType.VideoPlayback.ToString()
},
-
new NotificationTypeInfo
{
Type = NotificationType.AudioPlaybackStopped.ToString()
},
-
new NotificationTypeInfo
{
Type = NotificationType.VideoPlaybackStopped.ToString()
},
-
new NotificationTypeInfo
{
Type = NotificationType.CameraImageUploaded.ToString()
},
-
new NotificationTypeInfo
{
Type = NotificationType.UserLockedOut.ToString()
- }
- };
-
- if (!_appHost.CanSelfUpdate)
- {
- knownTypes.Add(new NotificationTypeInfo
+ },
+ new NotificationTypeInfo
{
Type = NotificationType.ApplicationUpdateAvailable.ToString()
- });
- }
+ }
+ };
foreach (var type in knownTypes)
{
diff --git a/Emby.Notifications/Notifications.cs b/Emby.Notifications/Notifications.cs
index d3290479f..449331f9c 100644
--- a/Emby.Notifications/Notifications.cs
+++ b/Emby.Notifications/Notifications.cs
@@ -65,7 +65,7 @@ namespace Emby.Notifications
_localization = localization;
_activityManager = activityManager;
- _coreNotificationTypes = new CoreNotificationTypes(localization, appHost).GetNotificationTypes().Select(i => i.Type).ToArray();
+ _coreNotificationTypes = new CoreNotificationTypes(localization).GetNotificationTypes().Select(i => i.Type).ToArray();
}
public Task RunAsync()
@@ -127,7 +127,7 @@ namespace Emby.Notifications
async void _appHost_HasUpdateAvailableChanged(object sender, EventArgs e)
{
// This notification is for users who can't auto-update (aka running as service)
- if (!_appHost.HasUpdateAvailable || _appHost.CanSelfUpdate)
+ if (!_appHost.HasUpdateAvailable)
{
return;
}
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
index f26cc4f62..65cdccfa5 100644
--- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
+++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
@@ -72,12 +72,6 @@ namespace Emby.Server.Implementations.AppBase
/// The plugin configurations path.
public string PluginConfigurationsPath => Path.Combine(PluginsPath, "configurations");
- ///
- /// Gets the path to where temporary update files will be stored
- ///
- /// The plugin configurations path.
- public string TempUpdatePath => Path.Combine(ProgramDataPath, "updates");
-
///
/// Gets the path to the log directory
///
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index ae020826d..fa8cc5c7e 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -123,12 +123,6 @@ namespace Emby.Server.Implementations
/// true if this instance can self restart; otherwise, false.
public abstract bool CanSelfRestart { get; }
- ///
- /// Gets or sets a value indicating whether this instance can self update.
- ///
- /// true if this instance can self update; otherwise, false.
- public virtual bool CanSelfUpdate => false;
-
public virtual bool CanLaunchWebBrowser
{
get
@@ -1458,7 +1452,6 @@ namespace Emby.Server.Implementations
OperatingSystem = EnvironmentInfo.OperatingSystem.ToString(),
OperatingSystemDisplayName = EnvironmentInfo.OperatingSystemName,
CanSelfRestart = CanSelfRestart,
- CanSelfUpdate = CanSelfUpdate,
CanLaunchWebBrowser = CanLaunchWebBrowser,
WanAddress = wanAddress,
HasUpdateAvailable = HasUpdateAvailable,
@@ -1757,21 +1750,6 @@ namespace Emby.Server.Implementations
Plugins = list.ToArray();
}
- ///
- /// Updates the application.
- ///
- /// The package that contains the update
- /// The cancellation token.
- /// The progress.
- public async Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress progress)
- {
- await InstallationManager.InstallPackage(package, false, progress, cancellationToken).ConfigureAwait(false);
-
- HasUpdateAvailable = false;
-
- OnApplicationUpdated(package);
- }
-
///
/// This returns localhost in the case of no external dns, and the hostname if the
/// dns is prefixed with a valid Uri prefix.
diff --git a/MediaBrowser.Common/Configuration/IApplicationPaths.cs b/MediaBrowser.Common/Configuration/IApplicationPaths.cs
index 27092c0e1..cb4e8bf5f 100644
--- a/MediaBrowser.Common/Configuration/IApplicationPaths.cs
+++ b/MediaBrowser.Common/Configuration/IApplicationPaths.cs
@@ -41,12 +41,6 @@ namespace MediaBrowser.Common.Configuration
/// The plugin configurations path.
string PluginConfigurationsPath { get; }
- ///
- /// Gets the path to where temporary update files will be stored
- ///
- /// The plugin configurations path.
- string TempUpdatePath { get; }
-
///
/// Gets the path to the log directory
///
diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs
index 6891152ee..3a4098612 100644
--- a/MediaBrowser.Common/IApplicationHost.cs
+++ b/MediaBrowser.Common/IApplicationHost.cs
@@ -72,12 +72,6 @@ namespace MediaBrowser.Common
/// The application user agent.
string ApplicationUserAgent { get; }
- ///
- /// Gets or sets a value indicating whether this instance can self update.
- ///
- /// true if this instance can self update; otherwise, false.
- bool CanSelfUpdate { get; }
-
///
/// Gets the exports.
///
@@ -86,12 +80,6 @@ namespace MediaBrowser.Common
/// IEnumerable{``0}.
IEnumerable GetExports(bool manageLifetime = true);
- ///
- /// Updates the application.
- ///
- /// Task.
- Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress progress);
-
///
/// Resolves this instance.
///
diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs
index d9ed68b27..581a1069c 100644
--- a/MediaBrowser.Model/System/SystemInfo.cs
+++ b/MediaBrowser.Model/System/SystemInfo.cs
@@ -60,12 +60,6 @@ namespace MediaBrowser.Model.System
/// true if this instance can self restart; otherwise, false.
public bool CanSelfRestart { get; set; }
- ///
- /// Gets or sets a value indicating whether this instance can self update.
- ///
- /// true if this instance can self update; otherwise, false.
- public bool CanSelfUpdate { get; set; }
-
public bool CanLaunchWebBrowser { get; set; }
///
--
cgit v1.2.3