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

Eagerly populate skin metadata to allow usage in hashing computation

This commit is contained in:
Dean Herbert 2020-09-14 23:31:03 +09:00
parent 91d37e0459
commit 1884e0167b
2 changed files with 16 additions and 7 deletions

View File

@ -321,11 +321,10 @@ namespace osu.Game.Database
LogForModel(item, "Beginning import...");
item.Files = archive != null ? createFileInfos(archive, Files) : new List<TFileModel>();
item.Hash = ComputeHash(item, archive);
await Populate(item, archive, cancellationToken);
item.Hash = ComputeHash(item, archive);
using (var write = ContextFactory.GetForWrite()) // used to share a context for full import. keep in mind this will block all writes.
{
try

View File

@ -91,6 +91,10 @@ namespace osu.Game.Skinning
protected override string ComputeHash(SkinInfo item, ArchiveReader reader = null)
{
// we need to populate early to create a hash based off skin.ini contents
if (item.Name?.Contains(".osk") == true)
populateMetadata(item);
if (item.Creator != null && item.Creator != unknown_creator_string)
{
// this is the optimal way to hash legacy skins, but will need to be reconsidered when we move forward with skin implementation.
@ -106,17 +110,23 @@ namespace osu.Game.Skinning
{
await base.Populate(model, archive, cancellationToken);
Skin reference = GetSkin(model);
if (model.Name?.Contains(".osk") == true)
populateMetadata(model);
}
private void populateMetadata(SkinInfo item)
{
Skin reference = GetSkin(item);
if (!string.IsNullOrEmpty(reference.Configuration.SkinInfo.Name))
{
model.Name = reference.Configuration.SkinInfo.Name;
model.Creator = reference.Configuration.SkinInfo.Creator;
item.Name = reference.Configuration.SkinInfo.Name;
item.Creator = reference.Configuration.SkinInfo.Creator;
}
else
{
model.Name = model.Name.Replace(".osk", "");
model.Creator ??= unknown_creator_string;
item.Name = item.Name.Replace(".osk", "");
item.Creator ??= unknown_creator_string;
}
}