mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Hash skins based on name, not skin.ini contents
It is feasible that a user may be changing the contents of skin.ini without changing the skin name / author. Such changes should not create a new skin if already imported.
This commit is contained in:
@ -253,6 +253,9 @@ namespace osu.Game.Database
|
||||
/// Generally should include all file types which determine the file's uniqueness.
|
||||
/// Large files should be avoided if possible.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is only used by the default hash implementation. If <see cref="ComputeHash"/> is overridden, it will not be used.
|
||||
/// </remarks>
|
||||
protected abstract string[] HashableFileTypes { get; }
|
||||
|
||||
internal static void LogForModel(TModel model, string message, Exception e = null)
|
||||
@ -271,7 +274,7 @@ namespace osu.Game.Database
|
||||
/// <remarks>
|
||||
/// In the case of no matching files, a hash will be generated from the passed archive's <see cref="ArchiveReader.Name"/>.
|
||||
/// </remarks>
|
||||
private string computeHash(TModel item, ArchiveReader reader = null)
|
||||
protected virtual string ComputeHash(TModel item, ArchiveReader reader = null)
|
||||
{
|
||||
// for now, concatenate all .osu files in the set to create a unique hash.
|
||||
MemoryStream hashable = new MemoryStream();
|
||||
@ -318,10 +321,11 @@ 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
|
||||
@ -437,7 +441,7 @@ namespace osu.Game.Database
|
||||
{
|
||||
using (ContextFactory.GetForWrite())
|
||||
{
|
||||
item.Hash = computeHash(item);
|
||||
item.Hash = ComputeHash(item);
|
||||
ModelStore.Update(item);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user