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,6 +483,11 @@ 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;
|
||||||
|
|
||||||
|
// check if a set already exists with the same online id.
|
||||||
|
beatmapSet = beatmaps.BeatmapSets.FirstOrDefault(b => b.OnlineBeatmapSetID == metadata.OnlineBeatmapSetID);
|
||||||
|
|
||||||
|
if (beatmapSet == null)
|
||||||
|
{
|
||||||
beatmapSet = new BeatmapSetInfo
|
beatmapSet = new BeatmapSetInfo
|
||||||
{
|
{
|
||||||
OnlineBeatmapSetID = metadata.OnlineBeatmapSetID,
|
OnlineBeatmapSetID = metadata.OnlineBeatmapSetID,
|
||||||
@ -491,6 +496,7 @@ namespace osu.Game.Beatmaps
|
|||||||
Files = fileInfos,
|
Files = fileInfos,
|
||||||
Metadata = metadata
|
Metadata = metadata
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var mapNames = reader.Filenames.Where(f => f.EndsWith(".osu"));
|
var mapNames = reader.Filenames.Where(f => f.EndsWith(".osu"));
|
||||||
|
|
||||||
@ -510,6 +516,10 @@ namespace osu.Game.Beatmaps
|
|||||||
beatmap.BeatmapInfo.Hash = ms.ComputeSHA2Hash();
|
beatmap.BeatmapInfo.Hash = ms.ComputeSHA2Hash();
|
||||||
beatmap.BeatmapInfo.MD5Hash = ms.ComputeMD5Hash();
|
beatmap.BeatmapInfo.MD5Hash = ms.ComputeMD5Hash();
|
||||||
|
|
||||||
|
var existing = beatmaps.Beatmaps.FirstOrDefault(b => b.Hash == beatmap.BeatmapInfo.Hash || b.OnlineBeatmapID == beatmap.BeatmapInfo.OnlineBeatmapID);
|
||||||
|
|
||||||
|
if (existing == null)
|
||||||
|
{
|
||||||
// TODO: Diff beatmap metadata with set metadata and leave it here if necessary
|
// TODO: Diff beatmap metadata with set metadata and leave it here if necessary
|
||||||
beatmap.BeatmapInfo.Metadata = null;
|
beatmap.BeatmapInfo.Metadata = null;
|
||||||
|
|
||||||
@ -522,6 +532,7 @@ namespace osu.Game.Beatmaps
|
|||||||
beatmapSet.Beatmaps.Add(beatmap.BeatmapInfo);
|
beatmapSet.Beatmaps.Add(beatmap.BeatmapInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return beatmapSet;
|
return beatmapSet;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user