mirror of
https://github.com/osukey/osukey.git
synced 2025-05-20 21:17:32 +09:00
Ensure we correctly handle importing beatmaps/sets when the onlineID already exists locally
This commit is contained in:
parent
7d2bbc50a3
commit
d704e9cf7e
@ -483,14 +483,20 @@ namespace osu.Game.Beatmaps
|
|||||||
using (var stream = new StreamReader(reader.GetStream(mapName)))
|
using (var stream = new StreamReader(reader.GetStream(mapName)))
|
||||||
metadata = BeatmapDecoder.GetDecoder(stream).Decode(stream).Metadata;
|
metadata = BeatmapDecoder.GetDecoder(stream).Decode(stream).Metadata;
|
||||||
|
|
||||||
beatmapSet = new BeatmapSetInfo
|
// check if a set already exists with the same online id.
|
||||||
|
beatmapSet = beatmaps.BeatmapSets.FirstOrDefault(b => b.OnlineBeatmapSetID == metadata.OnlineBeatmapSetID);
|
||||||
|
|
||||||
|
if (beatmapSet == null)
|
||||||
{
|
{
|
||||||
OnlineBeatmapSetID = metadata.OnlineBeatmapSetID,
|
beatmapSet = new BeatmapSetInfo
|
||||||
Beatmaps = new List<BeatmapInfo>(),
|
{
|
||||||
Hash = hash,
|
OnlineBeatmapSetID = metadata.OnlineBeatmapSetID,
|
||||||
Files = fileInfos,
|
Beatmaps = new List<BeatmapInfo>(),
|
||||||
Metadata = metadata
|
Hash = hash,
|
||||||
};
|
Files = fileInfos,
|
||||||
|
Metadata = metadata
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var mapNames = reader.Filenames.Where(f => f.EndsWith(".osu"));
|
var mapNames = reader.Filenames.Where(f => f.EndsWith(".osu"));
|
||||||
|
|
||||||
@ -510,16 +516,21 @@ namespace osu.Game.Beatmaps
|
|||||||
beatmap.BeatmapInfo.Hash = ms.ComputeSHA2Hash();
|
beatmap.BeatmapInfo.Hash = ms.ComputeSHA2Hash();
|
||||||
beatmap.BeatmapInfo.MD5Hash = ms.ComputeMD5Hash();
|
beatmap.BeatmapInfo.MD5Hash = ms.ComputeMD5Hash();
|
||||||
|
|
||||||
// TODO: Diff beatmap metadata with set metadata and leave it here if necessary
|
var existing = beatmaps.Beatmaps.FirstOrDefault(b => b.Hash == beatmap.BeatmapInfo.Hash || b.OnlineBeatmapID == beatmap.BeatmapInfo.OnlineBeatmapID);
|
||||||
beatmap.BeatmapInfo.Metadata = null;
|
|
||||||
|
|
||||||
RulesetInfo ruleset = rulesets.GetRuleset(beatmap.BeatmapInfo.RulesetID);
|
if (existing == null)
|
||||||
|
{
|
||||||
|
// TODO: Diff beatmap metadata with set metadata and leave it here if necessary
|
||||||
|
beatmap.BeatmapInfo.Metadata = null;
|
||||||
|
|
||||||
// TODO: this should be done in a better place once we actually need to dynamically update it.
|
RulesetInfo ruleset = rulesets.GetRuleset(beatmap.BeatmapInfo.RulesetID);
|
||||||
beatmap.BeatmapInfo.Ruleset = ruleset;
|
|
||||||
beatmap.BeatmapInfo.StarDifficulty = ruleset?.CreateInstance()?.CreateDifficultyCalculator(beatmap).Calculate() ?? 0;
|
|
||||||
|
|
||||||
beatmapSet.Beatmaps.Add(beatmap.BeatmapInfo);
|
// TODO: this should be done in a better place once we actually need to dynamically update it.
|
||||||
|
beatmap.BeatmapInfo.Ruleset = ruleset;
|
||||||
|
beatmap.BeatmapInfo.StarDifficulty = ruleset?.CreateInstance()?.CreateDifficultyCalculator(beatmap).Calculate() ?? 0;
|
||||||
|
|
||||||
|
beatmapSet.Beatmaps.Add(beatmap.BeatmapInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user