diff options
| author | JPVenson <github@jpb.email> | 2025-04-21 05:06:50 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-20 20:06:50 -0600 |
| commit | a0931baa8eb879898f4bc4049176ed3bdb4d80d1 (patch) | |
| tree | 69bca19c69930fb83a166ae9944273c4dd66fdb9 /Jellyfin.Api/Models | |
| parent | 5e4bd744c07d44d75c8e9eb7b6dc03b7ff4f147c (diff) | |
Add Api and startup check for sufficient storage capacity (#13888)
Diffstat (limited to 'Jellyfin.Api/Models')
3 files changed, 150 insertions, 0 deletions
diff --git a/Jellyfin.Api/Models/SystemInfoDtos/FolderStorageDto.cs b/Jellyfin.Api/Models/SystemInfoDtos/FolderStorageDto.cs new file mode 100644 index 000000000..00a965898 --- /dev/null +++ b/Jellyfin.Api/Models/SystemInfoDtos/FolderStorageDto.cs @@ -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 + }; + } +} diff --git a/Jellyfin.Api/Models/SystemInfoDtos/LibraryStorageDto.cs b/Jellyfin.Api/Models/SystemInfoDtos/LibraryStorageDto.cs new file mode 100644 index 000000000..c138324d2 --- /dev/null +++ b/Jellyfin.Api/Models/SystemInfoDtos/LibraryStorageDto.cs @@ -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() + }; + } +} diff --git a/Jellyfin.Api/Models/SystemInfoDtos/SystemStorageDto.cs b/Jellyfin.Api/Models/SystemInfoDtos/SystemStorageDto.cs new file mode 100644 index 000000000..a09042439 --- /dev/null +++ b/Jellyfin.Api/Models/SystemInfoDtos/SystemStorageDto.cs @@ -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() + }; + } +} |
