mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Add new properties to BeatmapInfo
to track online hash and updates
This commit is contained in:
parent
0bd4aee66c
commit
6ea380d649
@ -92,6 +92,16 @@ namespace osu.Game.Beatmaps
|
||||
[Indexed]
|
||||
public string MD5Hash { get; set; } = string.Empty;
|
||||
|
||||
public string OnlineMD5Hash { get; set; } = string.Empty;
|
||||
|
||||
public DateTimeOffset? LastOnlineUpdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this beatmap matches the online version, based on fetched online metadata.
|
||||
/// Will return <c>true</c> if no online metadata is available.
|
||||
/// </summary>
|
||||
public bool MatchesOnlineVersion => LastOnlineUpdate == null || MD5Hash == OnlineMD5Hash;
|
||||
|
||||
[JsonIgnore]
|
||||
public bool Hidden { get; set; }
|
||||
|
||||
|
@ -102,10 +102,13 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
beatmapInfo.BeatmapSet.Status = res.BeatmapSet?.Status ?? BeatmapOnlineStatus.None;
|
||||
beatmapInfo.BeatmapSet.OnlineID = res.OnlineBeatmapSetID;
|
||||
beatmapInfo.OnlineMD5Hash = res.MD5Hash;
|
||||
beatmapInfo.OnlineID = res.OnlineID;
|
||||
|
||||
beatmapInfo.Metadata.Author.OnlineID = res.AuthorID;
|
||||
|
||||
beatmapInfo.LastOnlineUpdate = DateTimeOffset.Now;
|
||||
|
||||
logForModel(set, $"Online retrieval mapped {beatmapInfo} to {res.OnlineBeatmapSetID} / {res.OnlineID}.");
|
||||
}
|
||||
}
|
||||
@ -190,7 +193,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
using (var cmd = db.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "SELECT beatmapset_id, beatmap_id, approved, user_id FROM osu_beatmaps WHERE checksum = @MD5Hash OR beatmap_id = @OnlineID OR filename = @Path";
|
||||
cmd.CommandText = "SELECT beatmapset_id, beatmap_id, approved, user_id, checksum FROM osu_beatmaps WHERE checksum = @MD5Hash OR beatmap_id = @OnlineID OR filename = @Path";
|
||||
|
||||
cmd.Parameters.Add(new SqliteParameter("@MD5Hash", beatmapInfo.MD5Hash));
|
||||
cmd.Parameters.Add(new SqliteParameter("@OnlineID", beatmapInfo.OnlineID));
|
||||
@ -209,8 +212,8 @@ namespace osu.Game.Beatmaps
|
||||
beatmapInfo.BeatmapSet.Status = status;
|
||||
beatmapInfo.BeatmapSet.OnlineID = reader.GetInt32(0);
|
||||
beatmapInfo.OnlineID = reader.GetInt32(1);
|
||||
|
||||
beatmapInfo.Metadata.Author.OnlineID = reader.GetInt32(3);
|
||||
beatmapInfo.OnlineMD5Hash = reader.GetString(4);
|
||||
|
||||
logForModel(set, $"Cached local retrieval for {beatmapInfo}.");
|
||||
return true;
|
||||
|
@ -56,6 +56,8 @@ namespace osu.Game.Beatmaps
|
||||
// Before we use below, we want to invalidate.
|
||||
workingBeatmapCache.Invalidate(beatmapSet);
|
||||
|
||||
// TODO: this call currently uses the local `online.db` lookup.
|
||||
// We probably don't want this to happen after initial import (as the data may be stale).
|
||||
onlineLookupQueue.Update(beatmapSet);
|
||||
|
||||
foreach (var beatmap in beatmapSet.Beatmaps)
|
||||
|
@ -61,8 +61,9 @@ namespace osu.Game.Database
|
||||
/// 15 2022-07-13 Added LastPlayed to BeatmapInfo.
|
||||
/// 16 2022-07-15 Removed HasReplay from ScoreInfo.
|
||||
/// 17 2022-07-16 Added CountryCode to RealmUser.
|
||||
/// 18 2022-07-19 Added OnlineMD5Hash and LastOnlineUpdate to BeatmapInfo.
|
||||
/// </summary>
|
||||
private const int schema_version = 17;
|
||||
private const int schema_version = 18;
|
||||
|
||||
/// <summary>
|
||||
/// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking realm retrieval during blocking periods.
|
||||
|
Loading…
Reference in New Issue
Block a user