mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Move database backup creation to async thread where possible
This commit is contained in:
@ -123,8 +123,18 @@ namespace osu.Game.Database
|
||||
|
||||
private void beginMigration()
|
||||
{
|
||||
const string backup_folder = "backups";
|
||||
|
||||
string backupSuffix = $"before_final_migration_{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}";
|
||||
|
||||
// required for initial backup.
|
||||
var realmBlockOperations = realm.BlockAllOperations();
|
||||
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
realm.CreateBackup(Path.Combine(backup_folder, $"client.{backupSuffix}.realm"), realmBlockOperations);
|
||||
efContextFactory.CreateBackup(Path.Combine(backup_folder, $"client.{backupSuffix}.db"));
|
||||
|
||||
using (var ef = efContextFactory.Get())
|
||||
{
|
||||
realm.Write(r =>
|
||||
@ -182,7 +192,6 @@ namespace osu.Game.Database
|
||||
true);
|
||||
|
||||
const string attachment_filename = "attach_me.zip";
|
||||
const string backup_folder = "backups";
|
||||
|
||||
var backupStorage = storage.GetStorageForDirectory(backup_folder);
|
||||
|
||||
@ -209,6 +218,8 @@ namespace osu.Game.Database
|
||||
// If we were to not do this, the migration would run another time the next time the user starts the game.
|
||||
deletePreRealmData();
|
||||
|
||||
realmBlockOperations.Dispose();
|
||||
|
||||
migrationCompleted.SetResult(true);
|
||||
efContextFactory.SetMigrationCompletion();
|
||||
});
|
||||
|
Reference in New Issue
Block a user