ServerApplicationPaths.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System.IO;
  2. using Emby.Server.Implementations.AppBase;
  3. using MediaBrowser.Controller;
  4. namespace Emby.Server.Implementations
  5. {
  6. /// <summary>
  7. /// Extends BaseApplicationPaths to add paths that are only applicable on the server.
  8. /// </summary>
  9. public class ServerApplicationPaths : BaseApplicationPaths, IServerApplicationPaths
  10. {
  11. /// <summary>
  12. /// Initializes a new instance of the <see cref="ServerApplicationPaths" /> class.
  13. /// </summary>
  14. /// <param name="programDataPath">The path for Jellyfin's data.</param>
  15. /// <param name="logDirectoryPath">The path for Jellyfin's logging directory.</param>
  16. /// <param name="configurationDirectoryPath">The path for Jellyfin's configuration directory.</param>
  17. /// <param name="cacheDirectoryPath">The path for Jellyfin's cache directory.</param>
  18. /// <param name="webDirectoryPath">The path for Jellyfin's web UI.</param>
  19. public ServerApplicationPaths(
  20. string programDataPath,
  21. string logDirectoryPath,
  22. string configurationDirectoryPath,
  23. string cacheDirectoryPath,
  24. string webDirectoryPath)
  25. : base(
  26. programDataPath,
  27. logDirectoryPath,
  28. configurationDirectoryPath,
  29. cacheDirectoryPath,
  30. webDirectoryPath)
  31. {
  32. // ProgramDataPath cannot change when the server is running, so cache these to avoid allocations.
  33. RootFolderPath = Path.Join(ProgramDataPath, "root");
  34. DefaultUserViewsPath = Path.Combine(RootFolderPath, "default");
  35. DefaultInternalMetadataPath = Path.Combine(ProgramDataPath, "metadata");
  36. InternalMetadataPath = DefaultInternalMetadataPath;
  37. }
  38. /// <summary>
  39. /// Gets the path to the base root media directory.
  40. /// </summary>
  41. /// <value>The root folder path.</value>
  42. public string RootFolderPath { get; }
  43. /// <summary>
  44. /// Gets the path to the default user view directory. Used if no specific user view is defined.
  45. /// </summary>
  46. /// <value>The default user views path.</value>
  47. public string DefaultUserViewsPath { get; }
  48. /// <summary>
  49. /// Gets the path to the People directory.
  50. /// </summary>
  51. /// <value>The people path.</value>
  52. public string PeoplePath => Path.Combine(InternalMetadataPath, "People");
  53. /// <inheritdoc />
  54. public string ArtistsPath => Path.Combine(InternalMetadataPath, "artists");
  55. /// <summary>
  56. /// Gets the path to the Genre directory.
  57. /// </summary>
  58. /// <value>The genre path.</value>
  59. public string GenrePath => Path.Combine(InternalMetadataPath, "Genre");
  60. /// <summary>
  61. /// Gets the path to the Genre directory.
  62. /// </summary>
  63. /// <value>The genre path.</value>
  64. public string MusicGenrePath => Path.Combine(InternalMetadataPath, "MusicGenre");
  65. /// <summary>
  66. /// Gets the path to the Studio directory.
  67. /// </summary>
  68. /// <value>The studio path.</value>
  69. public string StudioPath => Path.Combine(InternalMetadataPath, "Studio");
  70. /// <summary>
  71. /// Gets the path to the Year directory.
  72. /// </summary>
  73. /// <value>The year path.</value>
  74. public string YearPath => Path.Combine(InternalMetadataPath, "Year");
  75. /// <summary>
  76. /// Gets the path to the user configuration directory.
  77. /// </summary>
  78. /// <value>The user configuration directory path.</value>
  79. public string UserConfigurationDirectoryPath => Path.Combine(ConfigurationDirectoryPath, "users");
  80. /// <inheritdoc/>
  81. public string DefaultInternalMetadataPath { get; }
  82. /// <inheritdoc />
  83. public string InternalMetadataPath { get; set; }
  84. /// <inheritdoc />
  85. public string VirtualInternalMetadataPath => "%MetadataPath%";
  86. /// <inheritdoc/>
  87. public override void MakeSanityCheckOrThrow()
  88. {
  89. base.MakeSanityCheckOrThrow();
  90. CreateAndCheckMarker(RootFolderPath, "root");
  91. }
  92. }
  93. }