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:
parent
ec477a3ebf
commit
6a3e8e31de
@ -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);
|
||||
|
@ -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;
|
||||
});
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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; }
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user