Merge pull request #19029 from peppy/fix-skin-import-duplicate

Fix skins potentially being duplicated on batch import
This commit is contained in:
Dan Balasescu
2022-07-08 14:18:14 +09:00
committed by GitHub
2 changed files with 18 additions and 16 deletions

View File

@ -258,15 +258,13 @@ namespace osu.Game.Database
{
cancellationToken.ThrowIfCancellationRequested();
bool checkedExisting = false;
TModel? existing = null;
TModel? existing;
if (batchImport && archive != null)
{
// this is a fast bail condition to improve large import performance.
item.Hash = computeHashFast(archive);
checkedExisting = true;
existing = CheckForExisting(item, realm);
if (existing != null)
@ -311,8 +309,12 @@ namespace osu.Game.Database
// TODO: we may want to run this outside of the transaction.
Populate(item, archive, realm, cancellationToken);
if (!checkedExisting)
existing = CheckForExisting(item, realm);
// Populate() may have adjusted file content (see SkinImporter.updateSkinIniMetadata), so regardless of whether a fast check was done earlier, let's
// check for existing items a second time.
//
// If this is ever a performance issue, the fast-check hash can be compared and trigger a skip of this second check if it still matches.
// I don't think it is a huge deal doing a second indexed check, though.
existing = CheckForExisting(item, realm);
if (existing != null)
{