#pragma warning disable CA2227
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Enums;
using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries
{
///
/// An entity representing a file on disk.
///
public class MediaFile : IHasConcurrencyToken
{
///
/// Initializes a new instance of the class.
///
/// The path relative to the LibraryRoot.
/// The file kind.
/// The release.
public MediaFile(string path, MediaFileKind kind, Release release)
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException(nameof(path));
}
Path = path;
Kind = kind;
if (release == null)
{
throw new ArgumentNullException(nameof(release));
}
release.MediaFiles.Add(this);
MediaFileStreams = new HashSet();
}
///
/// Initializes a new instance of the class.
///
///
/// Default constructor. Protected due to required properties, but present because EF needs it.
///
protected MediaFile()
{
}
///
/// Gets or sets the id.
///
///
/// Identity, Indexed, Required.
///
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; protected set; }
///
/// Gets or sets the path relative to the library root.
///
///
/// Required, Max length = 65535.
///
[Required]
[MaxLength(65535)]
[StringLength(65535)]
public string Path { get; set; }
///
/// Gets or sets the kind of media file.
///
///
/// Required.
///
public MediaFileKind Kind { get; set; }
///
[ConcurrencyCheck]
public uint RowVersion { get; set; }
///
/// Gets or sets a collection containing the streams in this file.
///
public virtual ICollection MediaFileStreams { get; protected set; }
///
public void OnSavingChanges()
{
RowVersion++;
}
}
}