The Free Software Media System - Server Backend & API
Extract trickplay files into own subdirectory
Shadowghost6454a35ef831
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.csindex dc845b2d7e..f0cca9efd0 100644--- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs+++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs@@ -34,76 +34,46 @@ namespace Emby.Server.Implementations.AppBaseDataPath = 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");}}diff --git a/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs b/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.csindex cd73d67c3b..e94673bcec 100644--- a/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs+++ b/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs@@ -602,9 +602,11 @@ public class TrickplayManager : ITrickplayManager/// <inheritdoc />public string GetTrickplayDirectory(BaseItem item, int tileWidth, int tileHeight, int width, bool saveWithMedia = false){+ var basePath = _config.ApplicationPaths.TrickplayPath;+ var idString = item.Id.ToString("N", CultureInfo.InvariantCulture);var path = saveWithMedia? Path.Combine(item.ContainingFolderPath, Path.ChangeExtension(item.Path, ".trickplay"))- : Path.Combine(item.GetInternalMetadataPath(), "trickplay");+ : Path.Combine(basePath, idString);var subdirectory = string.Format(CultureInfo.InvariantCulture,diff --git a/Jellyfin.Server/Migrations/Routines/MoveTrickplayFiles.cs b/Jellyfin.Server/Migrations/Routines/MoveTrickplayFiles.csindex c1a9e88949..f4ebac3778 100644--- a/Jellyfin.Server/Migrations/Routines/MoveTrickplayFiles.cs+++ b/Jellyfin.Server/Migrations/Routines/MoveTrickplayFiles.cs@@ -39,7 +39,7 @@ public class MoveTrickplayFiles : IMigrationRoutine}/// <inheritdoc />- public Guid Id => new("4EF123D5-8EFF-4B0B-869D-3AED07A60E1B");+ public Guid Id => new("9540D44A-D8DC-11EF-9CBB-B77274F77C52");/// <inheritdoc />public string Name => "MoveTrickplayFiles";@@ -89,6 +89,12 @@ public class MoveTrickplayFiles : IMigrationRoutine{_fileSystem.MoveDirectory(oldPath, newPath);}++ oldPath = GetNewOldTrickplayDirectory(item, trickplayInfo.TileWidth, trickplayInfo.TileHeight, trickplayInfo.Width, false);+ if (_fileSystem.DirectoryExists(oldPath))+ {+ _fileSystem.MoveDirectory(oldPath, newPath);+ }}} while (previousCount == Limit);@@ -101,4 +107,20 @@ public class MoveTrickplayFiles : IMigrationRoutinereturn width.HasValue ? Path.Combine(path, width.Value.ToString(CultureInfo.InvariantCulture)) : path;}++ private string GetNewOldTrickplayDirectory(BaseItem item, int tileWidth, int tileHeight, int width, bool saveWithMedia = false)+ {+ var path = saveWithMedia+ ? Path.Combine(item.ContainingFolderPath, Path.ChangeExtension(item.Path, ".trickplay"))+ : Path.Combine(item.GetInternalMetadataPath(), "trickplay");++ var subdirectory = string.Format(+ CultureInfo.InvariantCulture,+ "{0} - {1}x{2}",+ width.ToString(CultureInfo.InvariantCulture),+ tileWidth.ToString(CultureInfo.InvariantCulture),+ tileHeight.ToString(CultureInfo.InvariantCulture));++ return Path.Combine(path, subdirectory);+ }}diff --git a/MediaBrowser.Common/Configuration/IApplicationPaths.cs b/MediaBrowser.Common/Configuration/IApplicationPaths.csindex 57c6546675..7a8ab32361 100644--- a/MediaBrowser.Common/Configuration/IApplicationPaths.cs+++ b/MediaBrowser.Common/Configuration/IApplicationPaths.cs@@ -84,5 +84,11 @@ namespace MediaBrowser.Common.Configuration/// </summary>/// <value>The magic string used for virtual path manipulation.</value>string VirtualDataPath { get; }++ /// <summary>+ /// Gets the path used for storing trickplay files.+ /// </summary>+ /// <value>The trickplay path.</value>+ string TrickplayPath { get; }}}