MediaFile.cs 2.0 KB

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