Add Api and startup check for sufficient storage capacity (#13888)
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Net.Mime;
|
||||
using Jellyfin.Api.Attributes;
|
||||
using Jellyfin.Api.Constants;
|
||||
using Jellyfin.Api.Models.SystemInfoDtos;
|
||||
using MediaBrowser.Common.Api;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
@@ -71,6 +72,19 @@ public class SystemController : BaseJellyfinApiController
|
||||
public ActionResult<SystemInfo> GetSystemInfo()
|
||||
=> _systemManager.GetSystemInfo(Request);
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the server.
|
||||
/// </summary>
|
||||
/// <response code="200">Information retrieved.</response>
|
||||
/// <response code="403">User does not have permission to retrieve information.</response>
|
||||
/// <returns>A <see cref="SystemInfo"/> with info about the system.</returns>
|
||||
[HttpGet("Info/Storage")]
|
||||
[Authorize(Policy = Policies.RequiresElevation)]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
public ActionResult<SystemStorageDto> GetSystemStorage()
|
||||
=> Ok(SystemStorageDto.FromSystemStorageInfo(_systemManager.GetSystemStorageInfo()));
|
||||
|
||||
/// <summary>
|
||||
/// Gets public information about the server.
|
||||
/// </summary>
|
||||
|
||||
46
Jellyfin.Api/Models/SystemInfoDtos/FolderStorageDto.cs
Normal file
46
Jellyfin.Api/Models/SystemInfoDtos/FolderStorageDto.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using MediaBrowser.Model.System;
|
||||
|
||||
namespace Jellyfin.Api.Models.SystemInfoDtos;
|
||||
|
||||
/// <summary>
|
||||
/// Contains information about a specific folder.
|
||||
/// </summary>
|
||||
public record FolderStorageDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the path of the folder in question.
|
||||
/// </summary>
|
||||
public required string Path { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the free space of the underlying storage device of the <see cref="Path"/>.
|
||||
/// </summary>
|
||||
public long FreeSpace { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the used space of the underlying storage device of the <see cref="Path"/>.
|
||||
/// </summary>
|
||||
public long UsedSpace { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kind of storage device of the <see cref="Path"/>.
|
||||
/// </summary>
|
||||
public string? StorageType { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Device Identifier.
|
||||
/// </summary>
|
||||
public string? DeviceId { get; init; }
|
||||
|
||||
internal static FolderStorageDto FromFolderStorageInfo(FolderStorageInfo model)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Path = model.Path,
|
||||
FreeSpace = model.FreeSpace,
|
||||
UsedSpace = model.UsedSpace,
|
||||
StorageType = model.StorageType,
|
||||
DeviceId = model.DeviceId
|
||||
};
|
||||
}
|
||||
}
|
||||
37
Jellyfin.Api/Models/SystemInfoDtos/LibraryStorageDto.cs
Normal file
37
Jellyfin.Api/Models/SystemInfoDtos/LibraryStorageDto.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Model.System;
|
||||
|
||||
namespace Jellyfin.Api.Models.SystemInfoDtos;
|
||||
|
||||
/// <summary>
|
||||
/// Contains informations about a libraries storage informations.
|
||||
/// </summary>
|
||||
public record LibraryStorageDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Library Id.
|
||||
/// </summary>
|
||||
public required Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the library.
|
||||
/// </summary>
|
||||
public required string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the storage informations about the folders used in a library.
|
||||
/// </summary>
|
||||
public required IReadOnlyCollection<FolderStorageDto> Folders { get; set; }
|
||||
|
||||
internal static LibraryStorageDto FromLibraryStorageModel(LibraryStorageInfo model)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Folders = model.Folders.Select(FolderStorageDto.FromFolderStorageInfo).ToArray()
|
||||
};
|
||||
}
|
||||
}
|
||||
67
Jellyfin.Api/Models/SystemInfoDtos/SystemStorageDto.cs
Normal file
67
Jellyfin.Api/Models/SystemInfoDtos/SystemStorageDto.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Model.System;
|
||||
|
||||
namespace Jellyfin.Api.Models.SystemInfoDtos;
|
||||
|
||||
/// <summary>
|
||||
/// Contains informations about the systems storage.
|
||||
/// </summary>
|
||||
public record SystemStorageDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Storage information of the program data folder.
|
||||
/// </summary>
|
||||
public required FolderStorageDto ProgramDataFolder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Storage information of the web UI resources folder.
|
||||
/// </summary>
|
||||
public required FolderStorageDto WebFolder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Storage information of the folder where images are cached.
|
||||
/// </summary>
|
||||
public required FolderStorageDto ImageCacheFolder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Storage information of the cache folder.
|
||||
/// </summary>
|
||||
public required FolderStorageDto CacheFolder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Storage information of the folder where logfiles are saved to.
|
||||
/// </summary>
|
||||
public required FolderStorageDto LogFolder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Storage information of the folder where metadata is stored.
|
||||
/// </summary>
|
||||
public required FolderStorageDto InternalMetadataFolder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Storage information of the transcoding cache.
|
||||
/// </summary>
|
||||
public required FolderStorageDto TranscodingTempFolder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the storage informations of all libraries.
|
||||
/// </summary>
|
||||
public required IReadOnlyCollection<LibraryStorageDto> Libraries { get; set; }
|
||||
|
||||
internal static SystemStorageDto FromSystemStorageInfo(SystemStorageInfo model)
|
||||
{
|
||||
return new SystemStorageDto()
|
||||
{
|
||||
ProgramDataFolder = FolderStorageDto.FromFolderStorageInfo(model.ProgramDataFolder),
|
||||
WebFolder = FolderStorageDto.FromFolderStorageInfo(model.WebFolder),
|
||||
ImageCacheFolder = FolderStorageDto.FromFolderStorageInfo(model.ImageCacheFolder),
|
||||
CacheFolder = FolderStorageDto.FromFolderStorageInfo(model.CacheFolder),
|
||||
LogFolder = FolderStorageDto.FromFolderStorageInfo(model.LogFolder),
|
||||
InternalMetadataFolder = FolderStorageDto.FromFolderStorageInfo(model.InternalMetadataFolder),
|
||||
TranscodingTempFolder = FolderStorageDto.FromFolderStorageInfo(model.TranscodingTempFolder),
|
||||
Libraries = model.Libraries.Select(LibraryStorageDto.FromLibraryStorageModel).ToArray()
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user