mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 21:02:55 +08:00
Eagerly populate skin metadata to allow usage in hashing computation
This commit is contained in:
parent
91d37e0459
commit
1884e0167b
@ -321,11 +321,10 @@ namespace osu.Game.Database
|
|||||||
LogForModel(item, "Beginning import...");
|
LogForModel(item, "Beginning import...");
|
||||||
|
|
||||||
item.Files = archive != null ? createFileInfos(archive, Files) : new List<TFileModel>();
|
item.Files = archive != null ? createFileInfos(archive, Files) : new List<TFileModel>();
|
||||||
|
item.Hash = ComputeHash(item, archive);
|
||||||
|
|
||||||
await Populate(item, archive, cancellationToken);
|
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.
|
using (var write = ContextFactory.GetForWrite()) // used to share a context for full import. keep in mind this will block all writes.
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -91,6 +91,10 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
protected override string ComputeHash(SkinInfo item, ArchiveReader reader = null)
|
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)
|
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.
|
// 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);
|
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))
|
if (!string.IsNullOrEmpty(reference.Configuration.SkinInfo.Name))
|
||||||
{
|
{
|
||||||
model.Name = reference.Configuration.SkinInfo.Name;
|
item.Name = reference.Configuration.SkinInfo.Name;
|
||||||
model.Creator = reference.Configuration.SkinInfo.Creator;
|
item.Creator = reference.Configuration.SkinInfo.Creator;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
model.Name = model.Name.Replace(".osk", "");
|
item.Name = item.Name.Replace(".osk", "");
|
||||||
model.Creator ??= unknown_creator_string;
|
item.Creator ??= unknown_creator_string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user