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.
public MediaFile(string path, MediaFileKind kind)
{
ArgumentException.ThrowIfNullOrEmpty(path);
Path = path;
Kind = kind;
MediaFileStreams = new HashSet();
}
///
/// Gets the id.
///
///
/// Identity, Indexed, Required.
///
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
///
/// Gets or sets the path relative to the library root.
///
///
/// Required, Max length = 65535.
///
[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; private set; }
///
/// Gets a collection containing the streams in this file.
///
public virtual ICollection MediaFileStreams { get; private set; }
///
public void OnSavingChanges()
{
RowVersion++;
}
}
}