aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2025-08-03 17:27:17 -0400
committerGitHub <noreply@github.com>2025-08-03 17:27:17 -0400
commit4b6fb6c4bb2478badad068ce18aabe0c2955db48 (patch)
tree15f986ee62327cceb8f5c8f009bcf08d10cfaa66 /Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
parente7bc86ebb8496615e0b3f73eb4f13ab4c0913dc8 (diff)
parentdb7465e83d9cc07134a0bffad7ed17b1c7b873da (diff)
Merge branch 'master' into master
Diffstat (limited to 'Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs')
-rw-r--r--Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs104
1 files changed, 59 insertions, 45 deletions
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
index dc845b2d7..e74755ec3 100644
--- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
+++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
@@ -1,5 +1,8 @@
using System;
+using System.Collections.Generic;
using System.IO;
+using System.Linq;
+using Jellyfin.Extensions;
using MediaBrowser.Common.Configuration;
namespace Emby.Server.Implementations.AppBase
@@ -30,80 +33,91 @@ namespace Emby.Server.Implementations.AppBase
ConfigurationDirectoryPath = configurationDirectoryPath;
CachePath = cacheDirectoryPath;
WebPath = webDirectoryPath;
-
DataPath = Directory.CreateDirectory(Path.Combine(ProgramDataPath, "data")).FullName;
}
- /// <summary>
- /// Gets the path to the program data folder.
- /// </summary>
- /// <value>The program data path.</value>
+ /// <inheritdoc/>
public string ProgramDataPath { get; }
/// <inheritdoc/>
public string WebPath { get; }
- /// <summary>
- /// Gets the path to the system folder.
- /// </summary>
- /// <value>The path to the system folder.</value>
+ /// <inheritdoc/>
public string ProgramSystemPath { get; } = AppContext.BaseDirectory;
- /// <summary>
- /// Gets the folder path to the data directory.
- /// </summary>
- /// <value>The data directory.</value>
+ /// <inheritdoc/>
public string DataPath { get; }
/// <inheritdoc />
public string VirtualDataPath => "%AppDataPath%";
- /// <summary>
- /// Gets the image cache path.
- /// </summary>
- /// <value>The image cache path.</value>
+ /// <inheritdoc/>
public string ImageCachePath => Path.Combine(CachePath, "images");
- /// <summary>
- /// Gets the path to the plugin directory.
- /// </summary>
- /// <value>The plugins path.</value>
+ /// <inheritdoc/>
public string PluginsPath => Path.Combine(ProgramDataPath, "plugins");
- /// <summary>
- /// Gets the path to the plugin configurations directory.
- /// </summary>
- /// <value>The plugin configurations path.</value>
+ /// <inheritdoc/>
public string PluginConfigurationsPath => Path.Combine(PluginsPath, "configurations");
- /// <summary>
- /// Gets the path to the log directory.
- /// </summary>
- /// <value>The log directory path.</value>
+ /// <inheritdoc/>
public string LogDirectoryPath { get; }
- /// <summary>
- /// Gets the path to the application configuration root directory.
- /// </summary>
- /// <value>The configuration directory path.</value>
+ /// <inheritdoc/>
public string ConfigurationDirectoryPath { get; }
- /// <summary>
- /// Gets the path to the system configuration file.
- /// </summary>
- /// <value>The system configuration file path.</value>
+ /// <inheritdoc/>
public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml");
- /// <summary>
- /// Gets or sets the folder path to the cache directory.
- /// </summary>
- /// <value>The cache directory.</value>
+ /// <inheritdoc/>
public string CachePath { get; set; }
- /// <summary>
- /// Gets the folder path to the temp directory within the cache folder.
- /// </summary>
- /// <value>The temp directory.</value>
+ /// <inheritdoc/>
public string TempDirectory => Path.Join(Path.GetTempPath(), "jellyfin");
+
+ /// <inheritdoc />
+ public string TrickplayPath => Path.Combine(DataPath, "trickplay");
+
+ /// <inheritdoc />
+ public string BackupPath => Path.Combine(DataPath, "backups");
+
+ /// <inheritdoc />
+ public virtual void MakeSanityCheckOrThrow()
+ {
+ CreateAndCheckMarker(ConfigurationDirectoryPath, "config");
+ CreateAndCheckMarker(LogDirectoryPath, "log");
+ CreateAndCheckMarker(PluginsPath, "plugin");
+ CreateAndCheckMarker(ProgramDataPath, "data");
+ CreateAndCheckMarker(CachePath, "cache");
+ CreateAndCheckMarker(DataPath, "data");
+ }
+
+ /// <inheritdoc />
+ public void CreateAndCheckMarker(string path, string markerName, bool recursive = false)
+ {
+ Directory.CreateDirectory(path);
+
+ CheckOrCreateMarker(path, $".jellyfin-{markerName}", recursive);
+ }
+
+ private IEnumerable<string> GetMarkers(string path, bool recursive = false)
+ {
+ return Directory.EnumerateFiles(path, ".jellyfin-*", recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
+ }
+
+ private void CheckOrCreateMarker(string path, string markerName, bool recursive = false)
+ {
+ var otherMarkers = GetMarkers(path, recursive).FirstOrDefault(e => Path.GetFileName(e) != markerName);
+ if (otherMarkers != null)
+ {
+ throw new InvalidOperationException($"Exepected to find only {markerName} but found marker for {otherMarkers}.");
+ }
+
+ var markerPath = Path.Combine(path, markerName);
+ if (!File.Exists(markerPath))
+ {
+ FileHelper.CreateEmpty(markerPath);
+ }
+ }
}
}