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();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
bool checkedExisting = false;
|
TModel? existing;
|
||||||
TModel? existing = null;
|
|
||||||
|
|
||||||
if (batchImport && archive != null)
|
if (batchImport && archive != null)
|
||||||
{
|
{
|
||||||
// this is a fast bail condition to improve large import performance.
|
// this is a fast bail condition to improve large import performance.
|
||||||
item.Hash = computeHashFast(archive);
|
item.Hash = computeHashFast(archive);
|
||||||
|
|
||||||
checkedExisting = true;
|
|
||||||
existing = CheckForExisting(item, realm);
|
existing = CheckForExisting(item, realm);
|
||||||
|
|
||||||
if (existing != null)
|
if (existing != null)
|
||||||
|
@ -311,7 +309,11 @@ await Task.WhenAll(tasks.Select(async task =>
|
||||||
// TODO: we may want to run this outside of the transaction.
|
// TODO: we may want to run this outside of the transaction.
|
||||||
Populate(item, archive, realm, cancellationToken);
|
Populate(item, archive, realm, cancellationToken);
|
||||||
|
|
||||||
if (!checkedExisting)
|
// 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);
|
existing = CheckForExisting(item, realm);
|
||||||
|
|
||||||
if (existing != null)
|
if (existing != null)
|
||||||
|
|
Loading…
Reference in New Issue