mirror of https://github.com/ppy/osu
Fix skins potentially being duplicated on batch import
Resolves https://github.com/ppy/osu/discussions/19024#discussioncomment-3099200
This commit is contained in:
parent
7086779cf4
commit
cf1da1dd18
|
@ -258,15 +258,13 @@ await Task.WhenAll(tasks.Select(async task =>
|
|||
{
|
||||
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 @@ await Task.WhenAll(tasks.Select(async task =>
|
|||
// 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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue