Only check online matching when determining whether to save online metadata

After https://github.com/ppy/osu/pull/23362 I'm not sure the
`LocallyModified` check is doing anything useful. It was confusing me
really hard when trying to parse this logic, and it can misbehave (as
`None` will also pass the check).
This commit is contained in:
Bartłomiej Dach 2024-02-12 11:35:11 +01:00
parent 4f0ae4197a
commit 87702b3312
No known key found for this signature in database

View File

@ -57,13 +57,13 @@ namespace osu.Game.Beatmaps
beatmapInfo.BeatmapSet.OnlineID = res.BeatmapSetID; beatmapInfo.BeatmapSet.OnlineID = res.BeatmapSetID;
// Some metadata should only be applied if there's no local changes. // Some metadata should only be applied if there's no local changes.
if (shouldSaveOnlineMetadata(beatmapInfo)) if (beatmapInfo.MatchesOnlineVersion)
{ {
beatmapInfo.Status = res.BeatmapStatus; beatmapInfo.Status = res.BeatmapStatus;
beatmapInfo.Metadata.Author.OnlineID = res.AuthorID; beatmapInfo.Metadata.Author.OnlineID = res.AuthorID;
} }
if (beatmapInfo.BeatmapSet.Beatmaps.All(shouldSaveOnlineMetadata)) if (beatmapInfo.BeatmapSet.Beatmaps.All(b => b.MatchesOnlineVersion))
{ {
beatmapInfo.BeatmapSet.Status = res.BeatmapSetStatus ?? BeatmapOnlineStatus.None; beatmapInfo.BeatmapSet.Status = res.BeatmapSetStatus ?? BeatmapOnlineStatus.None;
beatmapInfo.BeatmapSet.DateRanked = res.DateRanked; beatmapInfo.BeatmapSet.DateRanked = res.DateRanked;
@ -115,12 +115,6 @@ namespace osu.Game.Beatmaps
return false; return false;
} }
/// <summary>
/// Check whether the provided beatmap is in a state where online "ranked" status metadata should be saved against it.
/// Handles the case where a user may have locally modified a beatmap in the editor and expects the local status to stick.
/// </summary>
private static bool shouldSaveOnlineMetadata(BeatmapInfo beatmapInfo) => beatmapInfo.MatchesOnlineVersion || beatmapInfo.Status != BeatmapOnlineStatus.LocallyModified;
public void Dispose() public void Dispose()
{ {
apiMetadataSource.Dispose(); apiMetadataSource.Dispose();