mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-16 03:03:40 +01:00
Optimize migrations (#13855)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user