mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 11:34:57 +02:00
Merge pull request #6648 from barronpm/implementations-warn1
This commit is contained in:
commit
6a575b3f77
13 changed files with 362 additions and 352 deletions
|
@ -249,55 +249,4 @@ namespace Emby.Server.Implementations.Data
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The disk synchronization mode, controls how aggressively SQLite will write data
|
|
||||||
/// all the way out to physical storage.
|
|
||||||
/// </summary>
|
|
||||||
public enum SynchronousMode
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// SQLite continues without syncing as soon as it has handed data off to the operating system.
|
|
||||||
/// </summary>
|
|
||||||
Off = 0,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// SQLite database engine will still sync at the most critical moments.
|
|
||||||
/// </summary>
|
|
||||||
Normal = 1,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// SQLite database engine will use the xSync method of the VFS
|
|
||||||
/// to ensure that all content is safely written to the disk surface prior to continuing.
|
|
||||||
/// </summary>
|
|
||||||
Full = 2,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// EXTRA synchronous is like FULL with the addition that the directory containing a rollback journal
|
|
||||||
/// is synced after that journal is unlinked to commit a transaction in DELETE mode.
|
|
||||||
/// </summary>
|
|
||||||
Extra = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Storage mode used by temporary database files.
|
|
||||||
/// </summary>
|
|
||||||
public enum TempStoreMode
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The compile-time C preprocessor macro SQLITE_TEMP_STORE
|
|
||||||
/// is used to determine where temporary tables and indices are stored.
|
|
||||||
/// </summary>
|
|
||||||
Default = 0,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Temporary tables and indices are stored in a file.
|
|
||||||
/// </summary>
|
|
||||||
File = 1,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Temporary tables and indices are kept in as if they were pure in-memory databases memory.
|
|
||||||
/// </summary>
|
|
||||||
Memory = 2
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,10 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
public class ManagedConnection : IDisposable
|
public class ManagedConnection : IDisposable
|
||||||
{
|
{
|
||||||
private SQLiteDatabaseConnection? _db;
|
|
||||||
private readonly SemaphoreSlim _writeLock;
|
private readonly SemaphoreSlim _writeLock;
|
||||||
|
|
||||||
|
private SQLiteDatabaseConnection? _db;
|
||||||
|
|
||||||
private bool _disposed = false;
|
private bool _disposed = false;
|
||||||
|
|
||||||
public ManagedConnection(SQLiteDatabaseConnection db, SemaphoreSlim writeLock)
|
public ManagedConnection(SQLiteDatabaseConnection db, SemaphoreSlim writeLock)
|
||||||
|
|
|
@ -46,6 +46,11 @@ namespace Emby.Server.Implementations.Data
|
||||||
private const string FromText = " from TypedBaseItems A";
|
private const string FromText = " from TypedBaseItems A";
|
||||||
private const string ChaptersTableName = "Chapters2";
|
private const string ChaptersTableName = "Chapters2";
|
||||||
|
|
||||||
|
private const string SaveItemCommandText =
|
||||||
|
@"replace into TypedBaseItems
|
||||||
|
(guid,type,data,Path,StartDate,EndDate,ChannelId,IsMovie,IsSeries,EpisodeTitle,IsRepeat,CommunityRating,CustomRating,IndexNumber,IsLocked,Name,OfficialRating,MediaType,Overview,ParentIndexNumber,PremiereDate,ProductionYear,ParentId,Genres,InheritedParentalRatingValue,SortName,ForcedSortName,RunTimeTicks,Size,DateCreated,DateModified,PreferredMetadataLanguage,PreferredMetadataCountryCode,Width,Height,DateLastRefreshed,DateLastSaved,IsInMixedFolder,LockedFields,Studios,Audio,ExternalServiceId,Tags,IsFolder,UnratedType,TopParentId,TrailerTypes,CriticRating,CleanName,PresentationUniqueKey,OriginalTitle,PrimaryVersionId,DateLastMediaAdded,Album,IsVirtualItem,SeriesName,UserDataKey,SeasonName,SeasonId,SeriesId,ExternalSeriesId,Tagline,ProviderIds,Images,ProductionLocations,ExtraIds,TotalBitrate,ExtraType,Artists,AlbumArtists,ExternalId,SeriesPresentationUniqueKey,ShowId,OwnerId)
|
||||||
|
values (@guid,@type,@data,@Path,@StartDate,@EndDate,@ChannelId,@IsMovie,@IsSeries,@EpisodeTitle,@IsRepeat,@CommunityRating,@CustomRating,@IndexNumber,@IsLocked,@Name,@OfficialRating,@MediaType,@Overview,@ParentIndexNumber,@PremiereDate,@ProductionYear,@ParentId,@Genres,@InheritedParentalRatingValue,@SortName,@ForcedSortName,@RunTimeTicks,@Size,@DateCreated,@DateModified,@PreferredMetadataLanguage,@PreferredMetadataCountryCode,@Width,@Height,@DateLastRefreshed,@DateLastSaved,@IsInMixedFolder,@LockedFields,@Studios,@Audio,@ExternalServiceId,@Tags,@IsFolder,@UnratedType,@TopParentId,@TrailerTypes,@CriticRating,@CleanName,@PresentationUniqueKey,@OriginalTitle,@PrimaryVersionId,@DateLastMediaAdded,@Album,@IsVirtualItem,@SeriesName,@UserDataKey,@SeasonName,@SeasonId,@SeriesId,@ExternalSeriesId,@Tagline,@ProviderIds,@Images,@ProductionLocations,@ExtraIds,@TotalBitrate,@ExtraType,@Artists,@AlbumArtists,@ExternalId,@SeriesPresentationUniqueKey,@ShowId,@OwnerId)";
|
||||||
|
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly IServerApplicationHost _appHost;
|
private readonly IServerApplicationHost _appHost;
|
||||||
private readonly ILocalizationManager _localization;
|
private readonly ILocalizationManager _localization;
|
||||||
|
@ -55,6 +60,231 @@ namespace Emby.Server.Implementations.Data
|
||||||
private readonly TypeMapper _typeMapper;
|
private readonly TypeMapper _typeMapper;
|
||||||
private readonly JsonSerializerOptions _jsonOptions;
|
private readonly JsonSerializerOptions _jsonOptions;
|
||||||
|
|
||||||
|
private readonly ItemFields[] _allItemFields = Enum.GetValues<ItemFields>();
|
||||||
|
|
||||||
|
private static readonly string[] _retriveItemColumns =
|
||||||
|
{
|
||||||
|
"type",
|
||||||
|
"data",
|
||||||
|
"StartDate",
|
||||||
|
"EndDate",
|
||||||
|
"ChannelId",
|
||||||
|
"IsMovie",
|
||||||
|
"IsSeries",
|
||||||
|
"EpisodeTitle",
|
||||||
|
"IsRepeat",
|
||||||
|
"CommunityRating",
|
||||||
|
"CustomRating",
|
||||||
|
"IndexNumber",
|
||||||
|
"IsLocked",
|
||||||
|
"PreferredMetadataLanguage",
|
||||||
|
"PreferredMetadataCountryCode",
|
||||||
|
"Width",
|
||||||
|
"Height",
|
||||||
|
"DateLastRefreshed",
|
||||||
|
"Name",
|
||||||
|
"Path",
|
||||||
|
"PremiereDate",
|
||||||
|
"Overview",
|
||||||
|
"ParentIndexNumber",
|
||||||
|
"ProductionYear",
|
||||||
|
"OfficialRating",
|
||||||
|
"ForcedSortName",
|
||||||
|
"RunTimeTicks",
|
||||||
|
"Size",
|
||||||
|
"DateCreated",
|
||||||
|
"DateModified",
|
||||||
|
"guid",
|
||||||
|
"Genres",
|
||||||
|
"ParentId",
|
||||||
|
"Audio",
|
||||||
|
"ExternalServiceId",
|
||||||
|
"IsInMixedFolder",
|
||||||
|
"DateLastSaved",
|
||||||
|
"LockedFields",
|
||||||
|
"Studios",
|
||||||
|
"Tags",
|
||||||
|
"TrailerTypes",
|
||||||
|
"OriginalTitle",
|
||||||
|
"PrimaryVersionId",
|
||||||
|
"DateLastMediaAdded",
|
||||||
|
"Album",
|
||||||
|
"CriticRating",
|
||||||
|
"IsVirtualItem",
|
||||||
|
"SeriesName",
|
||||||
|
"SeasonName",
|
||||||
|
"SeasonId",
|
||||||
|
"SeriesId",
|
||||||
|
"PresentationUniqueKey",
|
||||||
|
"InheritedParentalRatingValue",
|
||||||
|
"ExternalSeriesId",
|
||||||
|
"Tagline",
|
||||||
|
"ProviderIds",
|
||||||
|
"Images",
|
||||||
|
"ProductionLocations",
|
||||||
|
"ExtraIds",
|
||||||
|
"TotalBitrate",
|
||||||
|
"ExtraType",
|
||||||
|
"Artists",
|
||||||
|
"AlbumArtists",
|
||||||
|
"ExternalId",
|
||||||
|
"SeriesPresentationUniqueKey",
|
||||||
|
"ShowId",
|
||||||
|
"OwnerId"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly string _retriveItemColumnsSelectQuery = $"select {string.Join(',', _retriveItemColumns)} from TypedBaseItems where guid = @guid";
|
||||||
|
|
||||||
|
private static readonly string[] _mediaStreamSaveColumns =
|
||||||
|
{
|
||||||
|
"ItemId",
|
||||||
|
"StreamIndex",
|
||||||
|
"StreamType",
|
||||||
|
"Codec",
|
||||||
|
"Language",
|
||||||
|
"ChannelLayout",
|
||||||
|
"Profile",
|
||||||
|
"AspectRatio",
|
||||||
|
"Path",
|
||||||
|
"IsInterlaced",
|
||||||
|
"BitRate",
|
||||||
|
"Channels",
|
||||||
|
"SampleRate",
|
||||||
|
"IsDefault",
|
||||||
|
"IsForced",
|
||||||
|
"IsExternal",
|
||||||
|
"Height",
|
||||||
|
"Width",
|
||||||
|
"AverageFrameRate",
|
||||||
|
"RealFrameRate",
|
||||||
|
"Level",
|
||||||
|
"PixelFormat",
|
||||||
|
"BitDepth",
|
||||||
|
"IsAnamorphic",
|
||||||
|
"RefFrames",
|
||||||
|
"CodecTag",
|
||||||
|
"Comment",
|
||||||
|
"NalLengthSize",
|
||||||
|
"IsAvc",
|
||||||
|
"Title",
|
||||||
|
"TimeBase",
|
||||||
|
"CodecTimeBase",
|
||||||
|
"ColorPrimaries",
|
||||||
|
"ColorSpace",
|
||||||
|
"ColorTransfer"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly string _mediaStreamSaveColumnsInsertQuery =
|
||||||
|
$"insert into mediastreams ({string.Join(',', _mediaStreamSaveColumns)}) values ";
|
||||||
|
|
||||||
|
private static readonly string _mediaStreamSaveColumnsSelectQuery =
|
||||||
|
$"select {string.Join(',', _mediaStreamSaveColumns)} from mediastreams where ItemId=@ItemId";
|
||||||
|
|
||||||
|
private static readonly string[] _mediaAttachmentSaveColumns =
|
||||||
|
{
|
||||||
|
"ItemId",
|
||||||
|
"AttachmentIndex",
|
||||||
|
"Codec",
|
||||||
|
"CodecTag",
|
||||||
|
"Comment",
|
||||||
|
"Filename",
|
||||||
|
"MIMEType"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly string _mediaAttachmentSaveColumnsSelectQuery =
|
||||||
|
$"select {string.Join(',', _mediaAttachmentSaveColumns)} from mediaattachments where ItemId=@ItemId";
|
||||||
|
|
||||||
|
private static readonly string _mediaAttachmentInsertPrefix;
|
||||||
|
|
||||||
|
private static readonly HashSet<string> _programTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
"Program",
|
||||||
|
"TvChannel",
|
||||||
|
"LiveTvProgram",
|
||||||
|
"LiveTvTvChannel"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly HashSet<string> _programExcludeParentTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
"Series",
|
||||||
|
"Season",
|
||||||
|
"MusicAlbum",
|
||||||
|
"MusicArtist",
|
||||||
|
"PhotoAlbum"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly HashSet<string> _serviceTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
"TvChannel",
|
||||||
|
"LiveTvTvChannel"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly HashSet<string> _startDateTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
"Program",
|
||||||
|
"LiveTvProgram"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly HashSet<string> _seriesTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
"Book",
|
||||||
|
"AudioBook",
|
||||||
|
"Episode",
|
||||||
|
"Season"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly HashSet<string> _artistExcludeParentTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
"Series",
|
||||||
|
"Season",
|
||||||
|
"PhotoAlbum"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly HashSet<string> _artistsTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
"Audio",
|
||||||
|
"MusicAlbum",
|
||||||
|
"MusicVideo",
|
||||||
|
"AudioBook",
|
||||||
|
"AudioPodcast"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly Type[] _knownTypes =
|
||||||
|
{
|
||||||
|
typeof(LiveTvProgram),
|
||||||
|
typeof(LiveTvChannel),
|
||||||
|
typeof(Series),
|
||||||
|
typeof(Audio),
|
||||||
|
typeof(MusicAlbum),
|
||||||
|
typeof(MusicArtist),
|
||||||
|
typeof(MusicGenre),
|
||||||
|
typeof(MusicVideo),
|
||||||
|
typeof(Movie),
|
||||||
|
typeof(Playlist),
|
||||||
|
typeof(AudioBook),
|
||||||
|
typeof(Trailer),
|
||||||
|
typeof(BoxSet),
|
||||||
|
typeof(Episode),
|
||||||
|
typeof(Season),
|
||||||
|
typeof(Series),
|
||||||
|
typeof(Book),
|
||||||
|
typeof(CollectionFolder),
|
||||||
|
typeof(Folder),
|
||||||
|
typeof(Genre),
|
||||||
|
typeof(Person),
|
||||||
|
typeof(Photo),
|
||||||
|
typeof(PhotoAlbum),
|
||||||
|
typeof(Studio),
|
||||||
|
typeof(UserRootFolder),
|
||||||
|
typeof(UserView),
|
||||||
|
typeof(Video),
|
||||||
|
typeof(Year),
|
||||||
|
typeof(Channel),
|
||||||
|
typeof(AggregateFolder)
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly Dictionary<string, string> _types = GetTypeMapDictionary();
|
||||||
|
|
||||||
static SqliteItemRepository()
|
static SqliteItemRepository()
|
||||||
{
|
{
|
||||||
var queryPrefixText = new StringBuilder();
|
var queryPrefixText = new StringBuilder();
|
||||||
|
@ -115,6 +345,8 @@ namespace Emby.Server.Implementations.Data
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens the connection to the database.
|
/// Opens the connection to the database.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="userDataRepo">The user data repository.</param>
|
||||||
|
/// <param name="userManager">The user manager.</param>
|
||||||
public void Initialize(SqliteUserDataRepository userDataRepo, IUserManager userManager)
|
public void Initialize(SqliteUserDataRepository userDataRepo, IUserManager userManager)
|
||||||
{
|
{
|
||||||
const string CreateMediaStreamsTableCommand
|
const string CreateMediaStreamsTableCommand
|
||||||
|
@ -340,151 +572,12 @@ namespace Emby.Server.Implementations.Data
|
||||||
userDataRepo.Initialize(userManager, WriteLock, WriteConnection);
|
userDataRepo.Initialize(userManager, WriteLock, WriteConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly string[] _retriveItemColumns =
|
|
||||||
{
|
|
||||||
"type",
|
|
||||||
"data",
|
|
||||||
"StartDate",
|
|
||||||
"EndDate",
|
|
||||||
"ChannelId",
|
|
||||||
"IsMovie",
|
|
||||||
"IsSeries",
|
|
||||||
"EpisodeTitle",
|
|
||||||
"IsRepeat",
|
|
||||||
"CommunityRating",
|
|
||||||
"CustomRating",
|
|
||||||
"IndexNumber",
|
|
||||||
"IsLocked",
|
|
||||||
"PreferredMetadataLanguage",
|
|
||||||
"PreferredMetadataCountryCode",
|
|
||||||
"Width",
|
|
||||||
"Height",
|
|
||||||
"DateLastRefreshed",
|
|
||||||
"Name",
|
|
||||||
"Path",
|
|
||||||
"PremiereDate",
|
|
||||||
"Overview",
|
|
||||||
"ParentIndexNumber",
|
|
||||||
"ProductionYear",
|
|
||||||
"OfficialRating",
|
|
||||||
"ForcedSortName",
|
|
||||||
"RunTimeTicks",
|
|
||||||
"Size",
|
|
||||||
"DateCreated",
|
|
||||||
"DateModified",
|
|
||||||
"guid",
|
|
||||||
"Genres",
|
|
||||||
"ParentId",
|
|
||||||
"Audio",
|
|
||||||
"ExternalServiceId",
|
|
||||||
"IsInMixedFolder",
|
|
||||||
"DateLastSaved",
|
|
||||||
"LockedFields",
|
|
||||||
"Studios",
|
|
||||||
"Tags",
|
|
||||||
"TrailerTypes",
|
|
||||||
"OriginalTitle",
|
|
||||||
"PrimaryVersionId",
|
|
||||||
"DateLastMediaAdded",
|
|
||||||
"Album",
|
|
||||||
"CriticRating",
|
|
||||||
"IsVirtualItem",
|
|
||||||
"SeriesName",
|
|
||||||
"SeasonName",
|
|
||||||
"SeasonId",
|
|
||||||
"SeriesId",
|
|
||||||
"PresentationUniqueKey",
|
|
||||||
"InheritedParentalRatingValue",
|
|
||||||
"ExternalSeriesId",
|
|
||||||
"Tagline",
|
|
||||||
"ProviderIds",
|
|
||||||
"Images",
|
|
||||||
"ProductionLocations",
|
|
||||||
"ExtraIds",
|
|
||||||
"TotalBitrate",
|
|
||||||
"ExtraType",
|
|
||||||
"Artists",
|
|
||||||
"AlbumArtists",
|
|
||||||
"ExternalId",
|
|
||||||
"SeriesPresentationUniqueKey",
|
|
||||||
"ShowId",
|
|
||||||
"OwnerId"
|
|
||||||
};
|
|
||||||
|
|
||||||
private static readonly string _retriveItemColumnsSelectQuery = $"select {string.Join(',', _retriveItemColumns)} from TypedBaseItems where guid = @guid";
|
|
||||||
|
|
||||||
private static readonly string[] _mediaStreamSaveColumns =
|
|
||||||
{
|
|
||||||
"ItemId",
|
|
||||||
"StreamIndex",
|
|
||||||
"StreamType",
|
|
||||||
"Codec",
|
|
||||||
"Language",
|
|
||||||
"ChannelLayout",
|
|
||||||
"Profile",
|
|
||||||
"AspectRatio",
|
|
||||||
"Path",
|
|
||||||
"IsInterlaced",
|
|
||||||
"BitRate",
|
|
||||||
"Channels",
|
|
||||||
"SampleRate",
|
|
||||||
"IsDefault",
|
|
||||||
"IsForced",
|
|
||||||
"IsExternal",
|
|
||||||
"Height",
|
|
||||||
"Width",
|
|
||||||
"AverageFrameRate",
|
|
||||||
"RealFrameRate",
|
|
||||||
"Level",
|
|
||||||
"PixelFormat",
|
|
||||||
"BitDepth",
|
|
||||||
"IsAnamorphic",
|
|
||||||
"RefFrames",
|
|
||||||
"CodecTag",
|
|
||||||
"Comment",
|
|
||||||
"NalLengthSize",
|
|
||||||
"IsAvc",
|
|
||||||
"Title",
|
|
||||||
"TimeBase",
|
|
||||||
"CodecTimeBase",
|
|
||||||
"ColorPrimaries",
|
|
||||||
"ColorSpace",
|
|
||||||
"ColorTransfer"
|
|
||||||
};
|
|
||||||
|
|
||||||
private static readonly string _mediaStreamSaveColumnsInsertQuery =
|
|
||||||
$"insert into mediastreams ({string.Join(',', _mediaStreamSaveColumns)}) values ";
|
|
||||||
|
|
||||||
private static readonly string _mediaStreamSaveColumnsSelectQuery =
|
|
||||||
$"select {string.Join(',', _mediaStreamSaveColumns)} from mediastreams where ItemId=@ItemId";
|
|
||||||
|
|
||||||
private static readonly string[] _mediaAttachmentSaveColumns =
|
|
||||||
{
|
|
||||||
"ItemId",
|
|
||||||
"AttachmentIndex",
|
|
||||||
"Codec",
|
|
||||||
"CodecTag",
|
|
||||||
"Comment",
|
|
||||||
"Filename",
|
|
||||||
"MIMEType"
|
|
||||||
};
|
|
||||||
|
|
||||||
private static readonly string _mediaAttachmentSaveColumnsSelectQuery =
|
|
||||||
$"select {string.Join(',', _mediaAttachmentSaveColumns)} from mediaattachments where ItemId=@ItemId";
|
|
||||||
|
|
||||||
private static readonly string _mediaAttachmentInsertPrefix;
|
|
||||||
|
|
||||||
private const string SaveItemCommandText =
|
|
||||||
@"replace into TypedBaseItems
|
|
||||||
(guid,type,data,Path,StartDate,EndDate,ChannelId,IsMovie,IsSeries,EpisodeTitle,IsRepeat,CommunityRating,CustomRating,IndexNumber,IsLocked,Name,OfficialRating,MediaType,Overview,ParentIndexNumber,PremiereDate,ProductionYear,ParentId,Genres,InheritedParentalRatingValue,SortName,ForcedSortName,RunTimeTicks,Size,DateCreated,DateModified,PreferredMetadataLanguage,PreferredMetadataCountryCode,Width,Height,DateLastRefreshed,DateLastSaved,IsInMixedFolder,LockedFields,Studios,Audio,ExternalServiceId,Tags,IsFolder,UnratedType,TopParentId,TrailerTypes,CriticRating,CleanName,PresentationUniqueKey,OriginalTitle,PrimaryVersionId,DateLastMediaAdded,Album,IsVirtualItem,SeriesName,UserDataKey,SeasonName,SeasonId,SeriesId,ExternalSeriesId,Tagline,ProviderIds,Images,ProductionLocations,ExtraIds,TotalBitrate,ExtraType,Artists,AlbumArtists,ExternalId,SeriesPresentationUniqueKey,ShowId,OwnerId)
|
|
||||||
values (@guid,@type,@data,@Path,@StartDate,@EndDate,@ChannelId,@IsMovie,@IsSeries,@EpisodeTitle,@IsRepeat,@CommunityRating,@CustomRating,@IndexNumber,@IsLocked,@Name,@OfficialRating,@MediaType,@Overview,@ParentIndexNumber,@PremiereDate,@ProductionYear,@ParentId,@Genres,@InheritedParentalRatingValue,@SortName,@ForcedSortName,@RunTimeTicks,@Size,@DateCreated,@DateModified,@PreferredMetadataLanguage,@PreferredMetadataCountryCode,@Width,@Height,@DateLastRefreshed,@DateLastSaved,@IsInMixedFolder,@LockedFields,@Studios,@Audio,@ExternalServiceId,@Tags,@IsFolder,@UnratedType,@TopParentId,@TrailerTypes,@CriticRating,@CleanName,@PresentationUniqueKey,@OriginalTitle,@PrimaryVersionId,@DateLastMediaAdded,@Album,@IsVirtualItem,@SeriesName,@UserDataKey,@SeasonName,@SeasonId,@SeriesId,@ExternalSeriesId,@Tagline,@ProviderIds,@Images,@ProductionLocations,@ExtraIds,@TotalBitrate,@ExtraType,@Artists,@AlbumArtists,@ExternalId,@SeriesPresentationUniqueKey,@ShowId,@OwnerId)";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Save a standard item in the repo.
|
/// Save a standard item in the repo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <exception cref="ArgumentNullException">item</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="item"/> is <c>null</c>.</exception>
|
||||||
public void SaveItem(BaseItem item, CancellationToken cancellationToken)
|
public void SaveItem(BaseItem item, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (item == null)
|
if (item == null)
|
||||||
|
@ -509,7 +602,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
connection.RunInTransaction(
|
connection.RunInTransaction(
|
||||||
db =>
|
db =>
|
||||||
{
|
{
|
||||||
using (var saveImagesStatement = base.PrepareStatement(db, "Update TypedBaseItems set Images=@Images where guid=@Id"))
|
using (var saveImagesStatement = PrepareStatement(db, "Update TypedBaseItems set Images=@Images where guid=@Id"))
|
||||||
{
|
{
|
||||||
saveImagesStatement.TryBind("@Id", item.Id.ToByteArray());
|
saveImagesStatement.TryBind("@Id", item.Id.ToByteArray());
|
||||||
saveImagesStatement.TryBind("@Images", SerializeImages(item.ImageInfos));
|
saveImagesStatement.TryBind("@Images", SerializeImages(item.ImageInfos));
|
||||||
|
@ -526,9 +619,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
/// <param name="items">The items.</param>
|
/// <param name="items">The items.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <exception cref="ArgumentNullException">
|
/// <exception cref="ArgumentNullException">
|
||||||
/// items
|
/// <paramref name="items"/> or <paramref name="cancellationToken"/> is <c>null</c>.
|
||||||
/// or
|
|
||||||
/// cancellationToken
|
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public void SaveItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken)
|
public void SaveItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
@ -1216,8 +1307,8 @@ namespace Emby.Server.Implementations.Data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">The id.</param>
|
/// <param name="id">The id.</param>
|
||||||
/// <returns>BaseItem.</returns>
|
/// <returns>BaseItem.</returns>
|
||||||
/// <exception cref="ArgumentNullException">id</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="id"/> is <c>null</c>.</exception>
|
||||||
/// <exception cref="ArgumentException"></exception>
|
/// <exception cref="ArgumentException"><paramr name="id"/> is <seealso cref="Guid.Empty"/>.</exception>
|
||||||
public BaseItem RetrieveItem(Guid id)
|
public BaseItem RetrieveItem(Guid id)
|
||||||
{
|
{
|
||||||
if (id == Guid.Empty)
|
if (id == Guid.Empty)
|
||||||
|
@ -1986,6 +2077,8 @@ namespace Emby.Server.Implementations.Data
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Saves the chapters.
|
/// Saves the chapters.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="id">The item id.</param>
|
||||||
|
/// <param name="chapters">The chapters.</param>
|
||||||
public void SaveChapters(Guid id, IReadOnlyList<ChapterInfo> chapters)
|
public void SaveChapters(Guid id, IReadOnlyList<ChapterInfo> chapters)
|
||||||
{
|
{
|
||||||
CheckDisposed();
|
CheckDisposed();
|
||||||
|
@ -2085,8 +2178,6 @@ namespace Emby.Server.Implementations.Data
|
||||||
|| query.IsLiked.HasValue;
|
|| query.IsLiked.HasValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly ItemFields[] _allFields = Enum.GetValues<ItemFields>();
|
|
||||||
|
|
||||||
private bool HasField(InternalItemsQuery query, ItemFields name)
|
private bool HasField(InternalItemsQuery query, ItemFields name)
|
||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
|
@ -2119,23 +2210,6 @@ namespace Emby.Server.Implementations.Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly HashSet<string> _programExcludeParentTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
|
||||||
{
|
|
||||||
"Series",
|
|
||||||
"Season",
|
|
||||||
"MusicAlbum",
|
|
||||||
"MusicArtist",
|
|
||||||
"PhotoAlbum"
|
|
||||||
};
|
|
||||||
|
|
||||||
private static readonly HashSet<string> _programTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
|
||||||
{
|
|
||||||
"Program",
|
|
||||||
"TvChannel",
|
|
||||||
"LiveTvProgram",
|
|
||||||
"LiveTvTvChannel"
|
|
||||||
};
|
|
||||||
|
|
||||||
private bool HasProgramAttributes(InternalItemsQuery query)
|
private bool HasProgramAttributes(InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
if (_programExcludeParentTypes.Contains(query.ParentType))
|
if (_programExcludeParentTypes.Contains(query.ParentType))
|
||||||
|
@ -2151,12 +2225,6 @@ namespace Emby.Server.Implementations.Data
|
||||||
return query.IncludeItemTypes.Any(x => _programTypes.Contains(x));
|
return query.IncludeItemTypes.Any(x => _programTypes.Contains(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly HashSet<string> _serviceTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
|
||||||
{
|
|
||||||
"TvChannel",
|
|
||||||
"LiveTvTvChannel"
|
|
||||||
};
|
|
||||||
|
|
||||||
private bool HasServiceName(InternalItemsQuery query)
|
private bool HasServiceName(InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
if (_programExcludeParentTypes.Contains(query.ParentType))
|
if (_programExcludeParentTypes.Contains(query.ParentType))
|
||||||
|
@ -2172,12 +2240,6 @@ namespace Emby.Server.Implementations.Data
|
||||||
return query.IncludeItemTypes.Any(x => _serviceTypes.Contains(x));
|
return query.IncludeItemTypes.Any(x => _serviceTypes.Contains(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly HashSet<string> _startDateTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
|
||||||
{
|
|
||||||
"Program",
|
|
||||||
"LiveTvProgram"
|
|
||||||
};
|
|
||||||
|
|
||||||
private bool HasStartDate(InternalItemsQuery query)
|
private bool HasStartDate(InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
if (_programExcludeParentTypes.Contains(query.ParentType))
|
if (_programExcludeParentTypes.Contains(query.ParentType))
|
||||||
|
@ -2213,22 +2275,6 @@ namespace Emby.Server.Implementations.Data
|
||||||
return query.IncludeItemTypes.Contains("Trailer", StringComparer.OrdinalIgnoreCase);
|
return query.IncludeItemTypes.Contains("Trailer", StringComparer.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly HashSet<string> _artistExcludeParentTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
|
||||||
{
|
|
||||||
"Series",
|
|
||||||
"Season",
|
|
||||||
"PhotoAlbum"
|
|
||||||
};
|
|
||||||
|
|
||||||
private static readonly HashSet<string> _artistsTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
|
||||||
{
|
|
||||||
"Audio",
|
|
||||||
"MusicAlbum",
|
|
||||||
"MusicVideo",
|
|
||||||
"AudioBook",
|
|
||||||
"AudioPodcast"
|
|
||||||
};
|
|
||||||
|
|
||||||
private bool HasArtistFields(InternalItemsQuery query)
|
private bool HasArtistFields(InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
if (_artistExcludeParentTypes.Contains(query.ParentType))
|
if (_artistExcludeParentTypes.Contains(query.ParentType))
|
||||||
|
@ -2244,14 +2290,6 @@ namespace Emby.Server.Implementations.Data
|
||||||
return query.IncludeItemTypes.Any(x => _artistsTypes.Contains(x));
|
return query.IncludeItemTypes.Any(x => _artistsTypes.Contains(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly HashSet<string> _seriesTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
|
||||||
{
|
|
||||||
"Book",
|
|
||||||
"AudioBook",
|
|
||||||
"Episode",
|
|
||||||
"Season"
|
|
||||||
};
|
|
||||||
|
|
||||||
private bool HasSeriesFields(InternalItemsQuery query)
|
private bool HasSeriesFields(InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
if (string.Equals(query.ParentType, "PhotoAlbum", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(query.ParentType, "PhotoAlbum", StringComparison.OrdinalIgnoreCase))
|
||||||
|
@ -2269,7 +2307,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
private void SetFinalColumnsToSelect(InternalItemsQuery query, List<string> columns)
|
private void SetFinalColumnsToSelect(InternalItemsQuery query, List<string> columns)
|
||||||
{
|
{
|
||||||
foreach (var field in _allFields)
|
foreach (var field in _allItemFields)
|
||||||
{
|
{
|
||||||
if (!HasField(query, field))
|
if (!HasField(query, field))
|
||||||
{
|
{
|
||||||
|
@ -4811,40 +4849,6 @@ namespace Emby.Server.Implementations.Data
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly Type[] _knownTypes =
|
|
||||||
{
|
|
||||||
typeof(LiveTvProgram),
|
|
||||||
typeof(LiveTvChannel),
|
|
||||||
typeof(Series),
|
|
||||||
typeof(Audio),
|
|
||||||
typeof(MusicAlbum),
|
|
||||||
typeof(MusicArtist),
|
|
||||||
typeof(MusicGenre),
|
|
||||||
typeof(MusicVideo),
|
|
||||||
typeof(Movie),
|
|
||||||
typeof(Playlist),
|
|
||||||
typeof(AudioBook),
|
|
||||||
typeof(Trailer),
|
|
||||||
typeof(BoxSet),
|
|
||||||
typeof(Episode),
|
|
||||||
typeof(Season),
|
|
||||||
typeof(Series),
|
|
||||||
typeof(Book),
|
|
||||||
typeof(CollectionFolder),
|
|
||||||
typeof(Folder),
|
|
||||||
typeof(Genre),
|
|
||||||
typeof(Person),
|
|
||||||
typeof(Photo),
|
|
||||||
typeof(PhotoAlbum),
|
|
||||||
typeof(Studio),
|
|
||||||
typeof(UserRootFolder),
|
|
||||||
typeof(UserView),
|
|
||||||
typeof(Video),
|
|
||||||
typeof(Year),
|
|
||||||
typeof(Channel),
|
|
||||||
typeof(AggregateFolder)
|
|
||||||
};
|
|
||||||
|
|
||||||
public void UpdateInheritedValues()
|
public void UpdateInheritedValues()
|
||||||
{
|
{
|
||||||
string sql = string.Join(
|
string sql = string.Join(
|
||||||
|
@ -4886,9 +4890,6 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not crazy about having this all the way down here, but at least it's in one place
|
|
||||||
private readonly Dictionary<string, string> _types = GetTypeMapDictionary();
|
|
||||||
|
|
||||||
private string MapIncludeItemTypes(string value)
|
private string MapIncludeItemTypes(string value)
|
||||||
{
|
{
|
||||||
if (_types.TryGetValue(value, out string result))
|
if (_types.TryGetValue(value, out string result))
|
||||||
|
|
|
@ -32,6 +32,9 @@ namespace Emby.Server.Implementations.Data
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens the connection to the database.
|
/// Opens the connection to the database.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="userManager">The user manager.</param>
|
||||||
|
/// <param name="dbLock">The lock to use for database IO.</param>
|
||||||
|
/// <param name="dbConnection">The connection to use for database IO.</param>
|
||||||
public void Initialize(IUserManager userManager, SemaphoreSlim dbLock, SQLiteDatabaseConnection dbConnection)
|
public void Initialize(IUserManager userManager, SemaphoreSlim dbLock, SQLiteDatabaseConnection dbConnection)
|
||||||
{
|
{
|
||||||
WriteLock.Dispose();
|
WriteLock.Dispose();
|
||||||
|
@ -49,8 +52,8 @@ namespace Emby.Server.Implementations.Data
|
||||||
connection.RunInTransaction(
|
connection.RunInTransaction(
|
||||||
db =>
|
db =>
|
||||||
{
|
{
|
||||||
db.ExecuteAll(string.Join(';', new[] {
|
db.ExecuteAll(string.Join(';', new[]
|
||||||
|
{
|
||||||
"create table if not exists UserDatas (key nvarchar not null, userId INT not null, rating float null, played bit not null, playCount int not null, isFavorite bit not null, playbackPositionTicks bigint not null, lastPlayedDate datetime null, AudioStreamIndex INT, SubtitleStreamIndex INT)",
|
"create table if not exists UserDatas (key nvarchar not null, userId INT not null, rating float null, played bit not null, playCount int not null, isFavorite bit not null, playbackPositionTicks bigint not null, lastPlayedDate datetime null, AudioStreamIndex INT, SubtitleStreamIndex INT)",
|
||||||
|
|
||||||
"drop index if exists idx_userdata",
|
"drop index if exists idx_userdata",
|
||||||
|
|
30
Emby.Server.Implementations/Data/SynchronouseMode.cs
Normal file
30
Emby.Server.Implementations/Data/SynchronouseMode.cs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
namespace Emby.Server.Implementations.Data;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The disk synchronization mode, controls how aggressively SQLite will write data
|
||||||
|
/// all the way out to physical storage.
|
||||||
|
/// </summary>
|
||||||
|
public enum SynchronousMode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// SQLite continues without syncing as soon as it has handed data off to the operating system.
|
||||||
|
/// </summary>
|
||||||
|
Off = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SQLite database engine will still sync at the most critical moments.
|
||||||
|
/// </summary>
|
||||||
|
Normal = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SQLite database engine will use the xSync method of the VFS
|
||||||
|
/// to ensure that all content is safely written to the disk surface prior to continuing.
|
||||||
|
/// </summary>
|
||||||
|
Full = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// EXTRA synchronous is like FULL with the addition that the directory containing a rollback journal
|
||||||
|
/// is synced after that journal is unlinked to commit a transaction in DELETE mode.
|
||||||
|
/// </summary>
|
||||||
|
Extra = 3
|
||||||
|
}
|
23
Emby.Server.Implementations/Data/TempStoreMode.cs
Normal file
23
Emby.Server.Implementations/Data/TempStoreMode.cs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
namespace Emby.Server.Implementations.Data;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Storage mode used by temporary database files.
|
||||||
|
/// </summary>
|
||||||
|
public enum TempStoreMode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The compile-time C preprocessor macro SQLITE_TEMP_STORE
|
||||||
|
/// is used to determine where temporary tables and indices are stored.
|
||||||
|
/// </summary>
|
||||||
|
Default = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Temporary tables and indices are stored in a file.
|
||||||
|
/// </summary>
|
||||||
|
File = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Temporary tables and indices are kept in as if they were pure in-memory databases memory.
|
||||||
|
/// </summary>
|
||||||
|
Memory = 2
|
||||||
|
}
|
|
@ -1,7 +1,8 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
namespace Emby.Server.Implementations
|
namespace Emby.Server.Implementations
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies the contract for server startup options.
|
||||||
|
/// </summary>
|
||||||
public interface IStartupOptions
|
public interface IStartupOptions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -10,7 +11,7 @@ namespace Emby.Server.Implementations
|
||||||
string? FFmpegPath { get; }
|
string? FFmpegPath { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value value indicating whether to run as service by the --service command line option.
|
/// Gets a value indicating whether to run as service by the --service command line option.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsService { get; }
|
bool IsService { get; }
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Data.Events;
|
using Jellyfin.Data.Events;
|
||||||
|
using Jellyfin.Extensions.Json;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using Jellyfin.Extensions.Json;
|
|
||||||
using MediaBrowser.Common.Progress;
|
using MediaBrowser.Common.Progress;
|
||||||
using MediaBrowser.Model.Tasks;
|
using MediaBrowser.Model.Tasks;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
@ -24,6 +24,11 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ScheduledTaskWorker : IScheduledTaskWorker
|
public class ScheduledTaskWorker : IScheduledTaskWorker
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The options for the json Serializer.
|
||||||
|
/// </summary>
|
||||||
|
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the application paths.
|
/// Gets or sets the application paths.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -66,11 +71,6 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private string _id;
|
private string _id;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The options for the json Serializer.
|
|
||||||
/// </summary>
|
|
||||||
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ScheduledTaskWorker" /> class.
|
/// Initializes a new instance of the <see cref="ScheduledTaskWorker" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -365,7 +365,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="options">Task options.</param>
|
/// <param name="options">Task options.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
/// <exception cref="InvalidOperationException">Cannot execute a Task that is already running</exception>
|
/// <exception cref="InvalidOperationException">Cannot execute a Task that is already running.</exception>
|
||||||
public async Task Execute(TaskOptions options)
|
public async Task Execute(TaskOptions options)
|
||||||
{
|
{
|
||||||
var task = Task.Run(async () => await ExecuteInternal(options).ConfigureAwait(false));
|
var task = Task.Run(async () => await ExecuteInternal(options).ConfigureAwait(false));
|
||||||
|
|
|
@ -19,16 +19,6 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TaskManager : ITaskManager
|
public class TaskManager : ITaskManager
|
||||||
{
|
{
|
||||||
public event EventHandler<GenericEventArgs<IScheduledTaskWorker>> TaskExecuting;
|
|
||||||
|
|
||||||
public event EventHandler<TaskCompletionEventArgs> TaskCompleted;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the list of Scheduled Tasks.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The scheduled tasks.</value>
|
|
||||||
public IScheduledTaskWorker[] ScheduledTasks { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _task queue.
|
/// The _task queue.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -53,10 +43,20 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
ScheduledTasks = Array.Empty<IScheduledTaskWorker>();
|
ScheduledTasks = Array.Empty<IScheduledTaskWorker>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public event EventHandler<GenericEventArgs<IScheduledTaskWorker>> TaskExecuting;
|
||||||
|
|
||||||
|
public event EventHandler<TaskCompletionEventArgs> TaskCompleted;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the list of Scheduled Tasks.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The scheduled tasks.</value>
|
||||||
|
public IScheduledTaskWorker[] ScheduledTasks { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cancels if running and queue.
|
/// Cancels if running and queue.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T">The task type.</typeparam>
|
||||||
/// <param name="options">Task options.</param>
|
/// <param name="options">Task options.</param>
|
||||||
public void CancelIfRunningAndQueue<T>(TaskOptions options)
|
public void CancelIfRunningAndQueue<T>(TaskOptions options)
|
||||||
where T : IScheduledTask
|
where T : IScheduledTask
|
||||||
|
@ -76,7 +76,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cancels if running.
|
/// Cancels if running.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T">The task type.</typeparam>
|
||||||
public void CancelIfRunning<T>()
|
public void CancelIfRunning<T>()
|
||||||
where T : IScheduledTask
|
where T : IScheduledTask
|
||||||
{
|
{
|
||||||
|
@ -87,7 +87,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Queues the scheduled task.
|
/// Queues the scheduled task.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T">The task type.</typeparam>
|
||||||
/// <param name="options">Task options.</param>
|
/// <param name="options">Task options.</param>
|
||||||
public void QueueScheduledTask<T>(TaskOptions options)
|
public void QueueScheduledTask<T>(TaskOptions options)
|
||||||
where T : IScheduledTask
|
where T : IScheduledTask
|
||||||
|
|
|
@ -39,6 +39,12 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ChapterImagesTask" /> class.
|
/// Initializes a new instance of the <see cref="ChapterImagesTask" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="libraryManager">The library manager.</param>.
|
||||||
|
/// <param name="itemRepo">The item repository.</param>
|
||||||
|
/// <param name="appPaths">The application paths.</param>
|
||||||
|
/// <param name="encodingManager">The encoding manager.</param>
|
||||||
|
/// <param name="fileSystem">The filesystem.</param>
|
||||||
|
/// <param name="localization">The localization manager.</param>
|
||||||
public ChapterImagesTask(
|
public ChapterImagesTask(
|
||||||
ILibraryManager libraryManager,
|
ILibraryManager libraryManager,
|
||||||
IItemRepository itemRepo,
|
IItemRepository itemRepo,
|
||||||
|
|
|
@ -22,6 +22,9 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="OptimizeDatabaseTask" /> class.
|
/// Initializes a new instance of the <see cref="OptimizeDatabaseTask" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="logger">The logger.</param>
|
||||||
|
/// <param name="localization">The localization manager.</param>
|
||||||
|
/// <param name="provider">The jellyfin DB context provider.</param>
|
||||||
public OptimizeDatabaseTask(
|
public OptimizeDatabaseTask(
|
||||||
ILogger<OptimizeDatabaseTask> logger,
|
ILogger<OptimizeDatabaseTask> logger,
|
||||||
ILocalizationManager localization,
|
ILocalizationManager localization,
|
||||||
|
|
|
@ -32,9 +32,24 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
_localization = localization;
|
_localization = localization;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Name => _localization.GetLocalizedString("TaskRefreshPeople");
|
||||||
|
|
||||||
|
public string Description => _localization.GetLocalizedString("TaskRefreshPeopleDescription");
|
||||||
|
|
||||||
|
public string Category => _localization.GetLocalizedString("TasksLibraryCategory");
|
||||||
|
|
||||||
|
public string Key => "RefreshPeople";
|
||||||
|
|
||||||
|
public bool IsHidden => false;
|
||||||
|
|
||||||
|
public bool IsEnabled => true;
|
||||||
|
|
||||||
|
public bool IsLogged => true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the triggers that define when the task will run.
|
/// Creates the triggers that define when the task will run.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <returns>An <see cref="IEnumerable{TaskTriggerInfo}"/> containing the default trigger infos for this task.</returns>
|
||||||
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
||||||
{
|
{
|
||||||
return new[]
|
return new[]
|
||||||
|
@ -57,19 +72,5 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
{
|
{
|
||||||
return _libraryManager.ValidatePeople(cancellationToken, progress);
|
return _libraryManager.ValidatePeople(cancellationToken, progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name => _localization.GetLocalizedString("TaskRefreshPeople");
|
|
||||||
|
|
||||||
public string Description => _localization.GetLocalizedString("TaskRefreshPeopleDescription");
|
|
||||||
|
|
||||||
public string Category => _localization.GetLocalizedString("TasksLibraryCategory");
|
|
||||||
|
|
||||||
public string Key => "RefreshPeople";
|
|
||||||
|
|
||||||
public bool IsHidden => false;
|
|
||||||
|
|
||||||
public bool IsEnabled => true;
|
|
||||||
|
|
||||||
public bool IsLogged => true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,18 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
_localization = localization;
|
_localization = localization;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Name => _localization.GetLocalizedString("TaskRefreshLibrary");
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Description => _localization.GetLocalizedString("TaskRefreshLibraryDescription");
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Category => _localization.GetLocalizedString("TasksLibraryCategory");
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Key => "RefreshLibrary";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the triggers that define when the task will run.
|
/// Creates the triggers that define when the task will run.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -60,26 +72,5 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
|
|
||||||
return ((LibraryManager)_libraryManager).ValidateMediaLibraryInternal(progress, cancellationToken);
|
return ((LibraryManager)_libraryManager).ValidateMediaLibraryInternal(progress, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public string Name => _localization.GetLocalizedString("TaskRefreshLibrary");
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public string Description => _localization.GetLocalizedString("TaskRefreshLibraryDescription");
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public string Category => _localization.GetLocalizedString("TasksLibraryCategory");
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public string Key => "RefreshLibrary";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public bool IsHidden => false;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public bool IsEnabled => true;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public bool IsLogged => true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue