Optimize migrations (#13855)

This commit is contained in:
Tim Eisele
2025-04-26 17:36:17 +02:00
committed by GitHub
parent a0b3b7335f
commit 9092130350
7 changed files with 128 additions and 153 deletions

View File

@@ -50,7 +50,7 @@ public interface IJellyfinDatabaseProvider
/// <summary>
/// Runs a full Database backup that can later be restored to.
/// </summary>
/// <param name="cancellationToken">A cancelation token.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>A key to identify the backup.</returns>
/// <exception cref="NotImplementedException">May throw an NotImplementException if this operation is not supported for this database.</exception>
Task<string> MigrationBackupFast(CancellationToken cancellationToken);
@@ -59,7 +59,7 @@ public interface IJellyfinDatabaseProvider
/// Restores a backup that has been previously created by <see cref="MigrationBackupFast(CancellationToken)"/>.
/// </summary>
/// <param name="key">The key to the backup from which the current database should be restored from.</param>
/// <param name="cancellationToken">A cancelation token.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
Task RestoreBackupFast(string key, CancellationToken cancellationToken);
}

View File

@@ -98,10 +98,7 @@ public sealed class SqliteDatabaseProvider : IJellyfinDatabaseProvider
var key = DateTime.UtcNow.ToString("yyyyMMddhhmmss", CultureInfo.InvariantCulture);
var path = Path.Combine(_applicationPaths.DataPath, "jellyfin.db");
var backupFile = Path.Combine(_applicationPaths.DataPath, BackupFolderName);
if (!Directory.Exists(backupFile))
{
Directory.CreateDirectory(backupFile);
}
Directory.CreateDirectory(backupFile);
backupFile = Path.Combine(backupFile, $"{key}_jellyfin.db");
File.Copy(path, backupFile);
@@ -118,7 +115,7 @@ public sealed class SqliteDatabaseProvider : IJellyfinDatabaseProvider
if (!File.Exists(backupFile))
{
_logger.LogCritical("Tried to restore a backup that does not exist.");
_logger.LogCritical("Tried to restore a backup that does not exist: {Key}", key);
return Task.CompletedTask;
}