| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using System.ComponentModel.DataAnnotations; |
| | | 4 | | using System.ComponentModel.DataAnnotations.Schema; |
| | | 5 | | using Jellyfin.Database.Implementations.Enums; |
| | | 6 | | using Jellyfin.Database.Implementations.Interfaces; |
| | | 7 | | |
| | | 8 | | namespace Jellyfin.Database.Implementations.Entities.Libraries |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// An entity representing a file on disk. |
| | | 12 | | /// </summary> |
| | | 13 | | public class MediaFile : IHasConcurrencyToken |
| | | 14 | | { |
| | | 15 | | /// <summary> |
| | | 16 | | /// Initializes a new instance of the <see cref="MediaFile"/> class. |
| | | 17 | | /// </summary> |
| | | 18 | | /// <param name="path">The path relative to the LibraryRoot.</param> |
| | | 19 | | /// <param name="kind">The file kind.</param> |
| | | 20 | | public MediaFile(string path, MediaFileKind kind) |
| | | 21 | | { |
| | 0 | 22 | | ArgumentException.ThrowIfNullOrEmpty(path); |
| | | 23 | | |
| | 0 | 24 | | Path = path; |
| | 0 | 25 | | Kind = kind; |
| | | 26 | | |
| | 0 | 27 | | MediaFileStreams = new HashSet<MediaFileStream>(); |
| | 0 | 28 | | } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Gets the id. |
| | | 32 | | /// </summary> |
| | | 33 | | /// <remarks> |
| | | 34 | | /// Identity, Indexed, Required. |
| | | 35 | | /// </remarks> |
| | | 36 | | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] |
| | | 37 | | public int Id { get; private set; } |
| | | 38 | | |
| | | 39 | | /// <summary> |
| | | 40 | | /// Gets or sets the path relative to the library root. |
| | | 41 | | /// </summary> |
| | | 42 | | /// <remarks> |
| | | 43 | | /// Required, Max length = 65535. |
| | | 44 | | /// </remarks> |
| | | 45 | | [MaxLength(65535)] |
| | | 46 | | [StringLength(65535)] |
| | | 47 | | public string Path { get; set; } |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Gets or sets the kind of media file. |
| | | 51 | | /// </summary> |
| | | 52 | | /// <remarks> |
| | | 53 | | /// Required. |
| | | 54 | | /// </remarks> |
| | | 55 | | public MediaFileKind Kind { get; set; } |
| | | 56 | | |
| | | 57 | | /// <inheritdoc /> |
| | | 58 | | [ConcurrencyCheck] |
| | | 59 | | public uint RowVersion { get; private set; } |
| | | 60 | | |
| | | 61 | | /// <summary> |
| | | 62 | | /// Gets a collection containing the streams in this file. |
| | | 63 | | /// </summary> |
| | | 64 | | public virtual ICollection<MediaFileStream> MediaFileStreams { get; private set; } |
| | | 65 | | |
| | | 66 | | /// <inheritdoc /> |
| | | 67 | | public void OnSavingChanges() |
| | | 68 | | { |
| | 0 | 69 | | RowVersion++; |
| | 0 | 70 | | } |
| | | 71 | | } |
| | | 72 | | } |