浏览代码

Extract trickplay files into own subdirectory

Shadowghost 4 月之前
父节点
当前提交
6454a35ef8

+ 14 - 44
Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs

@@ -34,76 +34,46 @@ namespace Emby.Server.Implementations.AppBase
             DataPath = Directory.CreateDirectory(Path.Combine(ProgramDataPath, "data")).FullName;
             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; }
         public string ProgramDataPath { get; }
 
 
         /// <inheritdoc/>
         /// <inheritdoc/>
         public string WebPath { get; }
         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;
         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; }
         public string DataPath { get; }
 
 
         /// <inheritdoc />
         /// <inheritdoc />
         public string VirtualDataPath => "%AppDataPath%";
         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");
         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");
         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");
         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; }
         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; }
         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");
         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; }
         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");
         public string TempDirectory => Path.Join(Path.GetTempPath(), "jellyfin");
+
+        /// <inheritdoc />
+        public string TrickplayPath => Path.Combine(DataPath, "trickplay");
     }
     }
 }
 }

+ 3 - 1
Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs

@@ -602,9 +602,11 @@ public class TrickplayManager : ITrickplayManager
     /// <inheritdoc />
     /// <inheritdoc />
     public string GetTrickplayDirectory(BaseItem item, int tileWidth, int tileHeight, int width, bool saveWithMedia = false)
     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
         var path = saveWithMedia
             ? Path.Combine(item.ContainingFolderPath, Path.ChangeExtension(item.Path, ".trickplay"))
             ? Path.Combine(item.ContainingFolderPath, Path.ChangeExtension(item.Path, ".trickplay"))
-            : Path.Combine(item.GetInternalMetadataPath(), "trickplay");
+            : Path.Combine(basePath, idString);
 
 
         var subdirectory = string.Format(
         var subdirectory = string.Format(
             CultureInfo.InvariantCulture,
             CultureInfo.InvariantCulture,

+ 23 - 1
Jellyfin.Server/Migrations/Routines/MoveTrickplayFiles.cs

@@ -39,7 +39,7 @@ public class MoveTrickplayFiles : IMigrationRoutine
     }
     }
 
 
     /// <inheritdoc />
     /// <inheritdoc />
-    public Guid Id => new("4EF123D5-8EFF-4B0B-869D-3AED07A60E1B");
+    public Guid Id => new("9540D44A-D8DC-11EF-9CBB-B77274F77C52");
 
 
     /// <inheritdoc />
     /// <inheritdoc />
     public string Name => "MoveTrickplayFiles";
     public string Name => "MoveTrickplayFiles";
@@ -89,6 +89,12 @@ public class MoveTrickplayFiles : IMigrationRoutine
                 {
                 {
                     _fileSystem.MoveDirectory(oldPath, newPath);
                     _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);
         } while (previousCount == Limit);
 
 
@@ -101,4 +107,20 @@ public class MoveTrickplayFiles : IMigrationRoutine
 
 
         return width.HasValue ? Path.Combine(path, width.Value.ToString(CultureInfo.InvariantCulture)) : path;
         return 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);
+    }
 }
 }

+ 6 - 0
MediaBrowser.Common/Configuration/IApplicationPaths.cs

@@ -84,5 +84,11 @@ namespace MediaBrowser.Common.Configuration
         /// </summary>
         /// </summary>
         /// <value>The magic string used for virtual path manipulation.</value>
         /// <value>The magic string used for virtual path manipulation.</value>
         string VirtualDataPath { get; }
         string VirtualDataPath { get; }
+
+        /// <summary>
+        /// Gets the path used for storing trickplay files.
+        /// </summary>
+        /// <value>The trickplay path.</value>
+        string TrickplayPath { get; }
     }
     }
 }
 }