1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 18:33:20 +08:00

Merge pull request #19478 from peppy/fix-collection-migration

Fix collection migration potentially deleting the database before finishing migration
This commit is contained in:
Salman Ahmed 2022-07-30 19:44:22 +03:00 committed by GitHub
commit 498c796c81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -794,22 +794,23 @@ namespace osu.Game.Database
break;
case 21:
try
{
// Migrate collections from external file to inside realm.
// We use the "legacy" importer because that is how things were actually being saved out until now.
var legacyCollectionImporter = new LegacyCollectionImporter(this);
if (legacyCollectionImporter.GetAvailableCount(storage).GetResultSafely() > 0)
{
legacyCollectionImporter.ImportFromStorage(storage);
storage.Delete("collection.db");
}
}
catch (Exception e)
legacyCollectionImporter.ImportFromStorage(storage).ContinueWith(task =>
{
if (task.Exception != null)
{
// can be removed 20221027 (just for initial safety).
Logger.Error(e, "Collections could not be migrated to realm. Please provide your \"collection.db\" to the dev team.");
Logger.Error(task.Exception.InnerException, "Collections could not be migrated to realm. Please provide your \"collection.db\" to the dev team.");
return;
}
storage.Move("collection.db", "collection.db.migrated");
});
}
break;