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

Remove PreUpdate, update hash in Save()

This commit is contained in:
smoogipoo 2020-06-08 14:40:17 +09:00
parent dfed27bd46
commit 443977aa8d
2 changed files with 8 additions and 25 deletions

View File

@ -203,7 +203,14 @@ namespace osu.Game.Beatmaps
stream.Seek(0, SeekOrigin.Begin);
UpdateFile(setInfo, setInfo.Files.Single(f => string.Equals(f.Filename, info.Path, StringComparison.OrdinalIgnoreCase)), stream);
using (ContextFactory.GetForWrite())
{
var beatmapInfo = setInfo.Beatmaps.Single(b => b.ID == info.ID);
beatmapInfo.MD5Hash = stream.ComputeMD5Hash();
stream.Seek(0, SeekOrigin.Begin);
UpdateFile(setInfo, setInfo.Files.Single(f => string.Equals(f.Filename, info.Path, StringComparison.OrdinalIgnoreCase)), stream);
}
}
var working = workingCache.FirstOrDefault(w => w.BeatmapInfo?.ID == info.ID);
@ -211,19 +218,6 @@ namespace osu.Game.Beatmaps
workingCache.Remove(working);
}
protected override void PreUpdate(BeatmapSetInfo item)
{
base.PreUpdate(item);
foreach (var info in item.Beatmaps)
{
var file = item.Files.SingleOrDefault(f => string.Equals(f.Filename, info.Path, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
using (var stream = Files.Store.GetStream(file))
info.MD5Hash = stream.ComputeMD5Hash();
}
}
private readonly WeakList<WorkingBeatmap> workingCache = new WeakList<WorkingBeatmap>();
/// <summary>

View File

@ -429,21 +429,10 @@ namespace osu.Game.Database
using (ContextFactory.GetForWrite())
{
item.Hash = computeHash(item);
PreUpdate(item);
ModelStore.Update(item);
}
}
/// <summary>
/// Perform any final actions before the update to database executes.
/// </summary>
/// <param name="item">The <typeparamref name="TModel"/> that is being updated.</param>
protected virtual void PreUpdate(TModel item)
{
}
/// <summary>
/// Delete an item from the manager.
/// Is a no-op for already deleted items.