Add declarative backups for migrations (#14135)

This commit is contained in:
JPVenson
2025-06-04 01:49:41 +03:00
committed by GitHub
parent 0c46431cbb
commit d5672ce407
15 changed files with 377 additions and 116 deletions

View File

@@ -64,6 +64,13 @@ public interface IJellyfinDatabaseProvider
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
Task RestoreBackupFast(string key, CancellationToken cancellationToken);
/// <summary>
/// Deletes a backup that has been previously created by <see cref="MigrationBackupFast(CancellationToken)"/>.
/// </summary>
/// <param name="key">The key to the backup which should be cleaned up.</param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
Task DeleteBackup(string key);
/// <summary>
/// Removes all contents from the database.
/// </summary>

View File

@@ -129,6 +129,21 @@ public sealed class SqliteDatabaseProvider : IJellyfinDatabaseProvider
return Task.CompletedTask;
}
/// <inheritdoc />
public Task DeleteBackup(string key)
{
var backupFile = Path.Combine(_applicationPaths.DataPath, BackupFolderName, $"{key}_jellyfin.db");
if (!File.Exists(backupFile))
{
_logger.LogCritical("Tried to delete a backup that does not exist: {Key}", key);
return Task.CompletedTask;
}
File.Delete(backupFile);
return Task.CompletedTask;
}
/// <inheritdoc/>
public async Task PurgeDatabase(JellyfinDbContext dbContext, IEnumerable<string>? tableNames)
{