1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

Centralise calls to reset online info of a BeatmapInfo

This commit is contained in:
Dean Herbert 2022-07-25 18:51:19 +09:00
parent ec477a3ebf
commit 6a3e8e31de
6 changed files with 18 additions and 8 deletions

View File

@ -797,7 +797,7 @@ namespace osu.Game.Tests.Database
await realm.Realm.WriteAsync(() =>
{
foreach (var b in imported.Beatmaps)
b.OnlineID = -1;
b.ResetOnlineInfo();
});
deleteBeatmapSet(imported, realm.Realm);

View File

@ -239,7 +239,7 @@ namespace osu.Game.Tests.Visual.Gameplay
createPlayerTest(false, r =>
{
var beatmap = createTestBeatmap(r);
beatmap.BeatmapInfo.OnlineID = -1;
beatmap.BeatmapInfo.ResetOnlineInfo();
return beatmap;
});

View File

@ -87,7 +87,7 @@ namespace osu.Game.Beatmaps
existingSetWithSameOnlineID.OnlineID = -1;
foreach (var b in existingSetWithSameOnlineID.Beatmaps)
b.OnlineID = -1;
b.ResetOnlineInfo();
LogForModel(beatmapSet, $"Found existing beatmap set with same OnlineID ({beatmapSet.OnlineID}). It will be disassociated and marked for deletion.");
}
@ -133,7 +133,7 @@ namespace osu.Game.Beatmaps
}
}
void resetIds() => beatmapSet.Beatmaps.ForEach(b => b.OnlineID = -1);
void resetIds() => beatmapSet.Beatmaps.ForEach(b => b.ResetOnlineInfo());
}
protected override bool CanSkipImport(BeatmapSetInfo existing, BeatmapSetInfo import)

View File

@ -109,6 +109,17 @@ namespace osu.Game.Beatmaps
[JsonIgnore]
public bool Hidden { get; set; }
/// <summary>
/// Reset any fetched online linking information (and history).
/// </summary>
public void ResetOnlineInfo()
{
OnlineID = -1;
LastOnlineUpdate = null;
OnlineMD5Hash = string.Empty;
Status = BeatmapOnlineStatus.None;
}
#region Properties we may not want persisted (but also maybe no harm?)
public double AudioLeadIn { get; set; }

View File

@ -164,8 +164,7 @@ namespace osu.Game.Beatmaps
// clear the hash, as that's what is used to match .osu files with their corresponding realm beatmaps.
newBeatmapInfo.Hash = string.Empty;
// clear online properties.
newBeatmapInfo.OnlineID = -1;
newBeatmapInfo.Status = BeatmapOnlineStatus.None;
newBeatmapInfo.ResetOnlineInfo();
return addDifficultyToSet(targetBeatmapSet, newBeatmap, referenceWorkingBeatmap.Skin);
}

View File

@ -88,7 +88,7 @@ namespace osu.Game.Beatmaps
if (req.CompletionState == APIRequestCompletionState.Failed)
{
logForModel(set, $"Online retrieval failed for {beatmapInfo}");
beatmapInfo.OnlineID = -1;
beatmapInfo.ResetOnlineInfo();
return;
}
@ -118,7 +118,7 @@ namespace osu.Game.Beatmaps
catch (Exception e)
{
logForModel(set, $"Online retrieval failed for {beatmapInfo} ({e.Message})");
beatmapInfo.OnlineID = -1;
beatmapInfo.ResetOnlineInfo();
}
}