Create backups before deleting scores and beatmaps from EF database

This commit is contained in:
Dean Herbert
2022-01-18 14:19:25 +09:00
parent b1a75ce480
commit 798482c941
2 changed files with 24 additions and 9 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.IO;
using System.Linq;
using System.Threading;
using Microsoft.EntityFrameworkCore.Storage;
@ -144,6 +145,13 @@ namespace osu.Game.Database
Database = { AutoTransactionsEnabled = false }
};
public void CreateBackup(string filename)
{
using (var source = storage.GetStream(DATABASE_NAME))
using (var destination = storage.GetStream(filename, FileAccess.Write, FileMode.CreateNew))
source.CopyTo(destination);
}
public void ResetDatabase()
{
lock (writeLock)