mirror of
https://github.com/ppy/osu.git
synced 2024-11-15 13:47:24 +08:00
Bring back matching by filename when performing online metadata lookups
This commit is contained in:
parent
2b0fd3558f
commit
7e3564cb4a
@ -33,7 +33,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
Debug.Assert(beatmapInfo.BeatmapSet != null);
|
Debug.Assert(beatmapInfo.BeatmapSet != null);
|
||||||
|
|
||||||
var req = new GetBeatmapRequest(beatmapInfo.MD5Hash);
|
var req = new GetBeatmapRequest(md5Hash: beatmapInfo.MD5Hash, filename: beatmapInfo.Path);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -43,10 +43,15 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
foreach (var beatmapInfo in beatmapSet.Beatmaps)
|
foreach (var beatmapInfo in beatmapSet.Beatmaps)
|
||||||
{
|
{
|
||||||
// note that it is KEY that the lookup here only uses MD5 inside
|
// note that these lookups DO NOT ACTUALLY FULLY GUARANTEE that the beatmap is what it claims it is,
|
||||||
// (see implementations of underlying `IOnlineBeatmapMetadataSource`s).
|
// i.e. the correctness of this lookup should be treated as APPROXIMATE AT WORST.
|
||||||
// anything else like online ID or filename can be manipulated, thus being inherently unreliable,
|
// this is because the beatmap filename is used as a fallback in some scenarios where the MD5 of the beatmap may mismatch.
|
||||||
// thus being unusable here for any purpose.
|
// this is considered to be an acceptable casualty so that things can continue to work as expected for users in some rare scenarios
|
||||||
|
// (stale beatmap files in beatmap packs, beatmap mirror desyncs).
|
||||||
|
// however, all this means that other places such as score submission ARE EXPECTED TO VERIFY THE MD5 OF THE BEATMAP AGAINST THE ONLINE ONE EXPLICITLY AGAIN.
|
||||||
|
//
|
||||||
|
// additionally note that the online ID stored to the map is EXPLICITLY NOT USED because some users in a silly attempt to "fix" things for themselves on stable
|
||||||
|
// would reuse online IDs of already submitted beatmaps, which means that information is pretty much expected to be bogus in a nonzero number of beatmapsets.
|
||||||
if (!tryLookup(beatmapInfo, preferOnlineFetch, out var res))
|
if (!tryLookup(beatmapInfo, preferOnlineFetch, out var res))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -89,7 +89,8 @@ namespace osu.Game.Beatmaps
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(beatmapInfo.MD5Hash))
|
if (string.IsNullOrEmpty(beatmapInfo.MD5Hash)
|
||||||
|
&& string.IsNullOrEmpty(beatmapInfo.Path))
|
||||||
{
|
{
|
||||||
onlineMetadata = null;
|
onlineMetadata = null;
|
||||||
return false;
|
return false;
|
||||||
@ -238,9 +239,10 @@ namespace osu.Game.Beatmaps
|
|||||||
using var cmd = db.CreateCommand();
|
using var cmd = db.CreateCommand();
|
||||||
|
|
||||||
cmd.CommandText =
|
cmd.CommandText =
|
||||||
@"SELECT beatmapset_id, beatmap_id, approved, user_id, checksum, last_update FROM osu_beatmaps WHERE checksum = @MD5Hash";
|
@"SELECT beatmapset_id, beatmap_id, approved, user_id, checksum, last_update FROM osu_beatmaps WHERE checksum = @MD5Hash OR filename = @Path";
|
||||||
|
|
||||||
cmd.Parameters.Add(new SqliteParameter(@"@MD5Hash", beatmapInfo.MD5Hash));
|
cmd.Parameters.Add(new SqliteParameter(@"@MD5Hash", beatmapInfo.MD5Hash));
|
||||||
|
cmd.Parameters.Add(new SqliteParameter(@"@Path", beatmapInfo.Path));
|
||||||
|
|
||||||
using var reader = cmd.ExecuteReader();
|
using var reader = cmd.ExecuteReader();
|
||||||
|
|
||||||
@ -277,10 +279,11 @@ namespace osu.Game.Beatmaps
|
|||||||
SELECT `b`.`beatmapset_id`, `b`.`beatmap_id`, `b`.`approved`, `b`.`user_id`, `b`.`checksum`, `b`.`last_update`, `s`.`submit_date`, `s`.`approved_date`
|
SELECT `b`.`beatmapset_id`, `b`.`beatmap_id`, `b`.`approved`, `b`.`user_id`, `b`.`checksum`, `b`.`last_update`, `s`.`submit_date`, `s`.`approved_date`
|
||||||
FROM `osu_beatmaps` AS `b`
|
FROM `osu_beatmaps` AS `b`
|
||||||
JOIN `osu_beatmapsets` AS `s` ON `s`.`beatmapset_id` = `b`.`beatmapset_id`
|
JOIN `osu_beatmapsets` AS `s` ON `s`.`beatmapset_id` = `b`.`beatmapset_id`
|
||||||
WHERE `b`.`checksum` = @MD5Hash
|
WHERE `b`.`checksum` = @MD5Hash OR `b`.`filename` = @Path
|
||||||
""";
|
""";
|
||||||
|
|
||||||
cmd.Parameters.Add(new SqliteParameter(@"@MD5Hash", beatmapInfo.MD5Hash));
|
cmd.Parameters.Add(new SqliteParameter(@"@MD5Hash", beatmapInfo.MD5Hash));
|
||||||
|
cmd.Parameters.Add(new SqliteParameter(@"@Path", beatmapInfo.Path));
|
||||||
|
|
||||||
using var reader = cmd.ExecuteReader();
|
using var reader = cmd.ExecuteReader();
|
||||||
|
|
||||||
|
@ -10,20 +10,20 @@ namespace osu.Game.Online.API.Requests
|
|||||||
{
|
{
|
||||||
public class GetBeatmapRequest : APIRequest<APIBeatmap>
|
public class GetBeatmapRequest : APIRequest<APIBeatmap>
|
||||||
{
|
{
|
||||||
public readonly int OnlineID = -1;
|
public readonly int OnlineID;
|
||||||
public readonly string? MD5Hash;
|
public readonly string? MD5Hash;
|
||||||
public readonly string? Filename;
|
public readonly string? Filename;
|
||||||
|
|
||||||
public GetBeatmapRequest(IBeatmapInfo beatmapInfo)
|
public GetBeatmapRequest(IBeatmapInfo beatmapInfo)
|
||||||
|
: this(onlineId: beatmapInfo.OnlineID, md5Hash: beatmapInfo.MD5Hash, filename: (beatmapInfo as BeatmapInfo)?.Path)
|
||||||
{
|
{
|
||||||
OnlineID = beatmapInfo.OnlineID;
|
|
||||||
MD5Hash = beatmapInfo.MD5Hash;
|
|
||||||
Filename = (beatmapInfo as BeatmapInfo)?.Path ?? string.Empty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GetBeatmapRequest(string md5Hash)
|
public GetBeatmapRequest(int onlineId = -1, string? md5Hash = null, string? filename = null)
|
||||||
{
|
{
|
||||||
|
OnlineID = onlineId;
|
||||||
MD5Hash = md5Hash;
|
MD5Hash = md5Hash;
|
||||||
|
Filename = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override WebRequest CreateWebRequest()
|
protected override WebRequest CreateWebRequest()
|
||||||
|
Loading…
Reference in New Issue
Block a user