< Summary - Jellyfin

Information
Class: Jellyfin.Database.Implementations.IJellyfinDatabaseProvider
Assembly: Jellyfin.Database.Implementations
File(s): /srv/git/jellyfin/src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 1
Coverable lines: 1
Total lines: 96
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 10/29/2026 - 12:17:11 AM Line coverage: 0% (0/1) Total lines: 96

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
RefreshStatistics(...)100%210%

File(s)

/srv/git/jellyfin/src/Jellyfin.Database/Jellyfin.Database.Implementations/IJellyfinDatabaseProvider.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Threading;
 4using System.Threading.Tasks;
 5using Jellyfin.Database.Implementations.DbConfiguration;
 6using Microsoft.EntityFrameworkCore;
 7
 8namespace Jellyfin.Database.Implementations;
 9
 10/// <summary>
 11/// Defines the type and extension points for multi database support.
 12/// </summary>
 13public interface IJellyfinDatabaseProvider
 14{
 15    /// <summary>
 16    /// Gets or Sets the Database Factory when initialisaition is done.
 17    /// </summary>
 18    IDbContextFactory<JellyfinDbContext>? DbContextFactory { get; set; }
 19
 20    /// <summary>
 21    /// Initialises jellyfins EFCore database access.
 22    /// </summary>
 23    /// <param name="options">The EFCore database options.</param>
 24    /// <param name="databaseConfiguration">The Jellyfin database options.</param>
 25    void Initialise(DbContextOptionsBuilder options, DatabaseConfigurationOptions databaseConfiguration);
 26
 27    /// <summary>
 28    /// Will be invoked when EFCore wants to build its model.
 29    /// </summary>
 30    /// <param name="modelBuilder">The ModelBuilder from EFCore.</param>
 31    void OnModelCreating(ModelBuilder modelBuilder);
 32
 33    /// <summary>
 34    /// Will be invoked when EFCore wants to configure its model.
 35    /// </summary>
 36    /// <param name="configurationBuilder">The ModelConfigurationBuilder from EFCore.</param>
 37    void ConfigureConventions(ModelConfigurationBuilder configurationBuilder);
 38
 39    /// <summary>
 40    /// If supported this should run any periodic maintaince tasks, reclaiming unused space and refreshing the query
 41    /// planner statistics. Also used after migrations have modified the database.
 42    /// </summary>
 43    /// <param name="cancellationToken">The token to abort the operation.</param>
 44    /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
 45    Task RunScheduledOptimisation(CancellationToken cancellationToken);
 46
 47    /// <summary>
 48    /// If supported this should refresh the query planner statistics, e.g. after a library scan changed the data.
 49    /// Unlike <see cref="RunScheduledOptimisation(CancellationToken)"/> it should not reclaim space, so that it stays
 50    /// cheap enough to run after every scan.
 51    /// </summary>
 52    /// <param name="cancellationToken">The token to abort the operation.</param>
 53    /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
 054    Task RefreshStatistics(CancellationToken cancellationToken) => Task.CompletedTask;
 55
 56    /// <summary>
 57    /// If supported this should perform any actions that are required on stopping the jellyfin server. This runs
 58    /// against a deadline imposed by the service manager, so unlike
 59    /// <see cref="RunScheduledOptimisation(CancellationToken)"/> it should only do work whose cost does not grow with
 60    /// the size of the database.
 61    /// </summary>
 62    /// <param name="cancellationToken">The token that will be used to abort the operation.</param>
 63    /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
 64    Task RunShutdownTask(CancellationToken cancellationToken);
 65
 66    /// <summary>
 67    /// Runs a full Database backup that can later be restored to.
 68    /// </summary>
 69    /// <param name="cancellationToken">A cancellation token.</param>
 70    /// <returns>A key to identify the backup.</returns>
 71    /// <exception cref="NotImplementedException">May throw an NotImplementException if this operation is not supported 
 72    Task<string> MigrationBackupFast(CancellationToken cancellationToken);
 73
 74    /// <summary>
 75    /// Restores a backup that has been previously created by <see cref="MigrationBackupFast(CancellationToken)"/>.
 76    /// </summary>
 77    /// <param name="key">The key to the backup from which the current database should be restored from.</param>
 78    /// <param name="cancellationToken">A cancellation token.</param>
 79    /// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
 80    Task RestoreBackupFast(string key, CancellationToken cancellationToken);
 81
 82    /// <summary>
 83    /// Deletes a backup that has been previously created by <see cref="MigrationBackupFast(CancellationToken)"/>.
 84    /// </summary>
 85    /// <param name="key">The key to the backup which should be cleaned up.</param>
 86    /// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
 87    Task DeleteBackup(string key);
 88
 89    /// <summary>
 90    /// Removes all contents from the database.
 91    /// </summary>
 92    /// <param name="dbContext">The Database context.</param>
 93    /// <param name="tableNames">The names of the tables to purge or null for all tables to be purged.</param>
 94    /// <returns>A Task.</returns>
 95    Task PurgeDatabase(JellyfinDbContext dbContext, IEnumerable<string>? tableNames);
 96}