1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-05 14:22:55 +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; break;
case 21: case 21:
try
{
// Migrate collections from external file to inside realm. // 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. // We use the "legacy" importer because that is how things were actually being saved out until now.
var legacyCollectionImporter = new LegacyCollectionImporter(this); var legacyCollectionImporter = new LegacyCollectionImporter(this);
if (legacyCollectionImporter.GetAvailableCount(storage).GetResultSafely() > 0) if (legacyCollectionImporter.GetAvailableCount(storage).GetResultSafely() > 0)
{ {
legacyCollectionImporter.ImportFromStorage(storage); legacyCollectionImporter.ImportFromStorage(storage).ContinueWith(task =>
storage.Delete("collection.db"); {
} if (task.Exception != null)
}
catch (Exception e)
{ {
// can be removed 20221027 (just for initial safety). // 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; break;