diff --git a/osu.Game/Beatmaps/BeatmapStore.cs b/osu.Game/Beatmaps/BeatmapStore.cs
index 092846170e..facb68e808 100644
--- a/osu.Game/Beatmaps/BeatmapStore.cs
+++ b/osu.Game/Beatmaps/BeatmapStore.cs
@@ -246,40 +246,39 @@ namespace osu.Game.Beatmaps
/// The imported beatmap, or an existing instance if it is already present.
private BeatmapSetInfo importToStorage(ArchiveReader reader)
{
+ // for now, concatenate all .osu files in the set to create a unique hash.
+ MemoryStream hashable = new MemoryStream();
+ foreach (string file in reader.Filenames.Where(f => f.EndsWith(".osu")))
+ using (Stream s = reader.GetStream(file))
+ s.CopyTo(hashable);
+
+ var hash = hashable.GetMd5Hash();
+
+ // check if this beatmap has already been imported and exit early if so.
+ var beatmapSet = beatmaps.QueryAndPopulate().FirstOrDefault(b => b.Hash == hash);
+ if (beatmapSet != null)
+ {
+ Undelete(beatmapSet);
+ return beatmapSet;
+ }
+
+ List fileInfos = new List();
+
+ // import files to store
+ foreach (string file in reader.Filenames)
+ using (Stream s = reader.GetStream(file))
+ fileInfos.Add(files.Add(s, file));
+
BeatmapMetadata metadata;
using (var stream = new StreamReader(reader.GetStream(reader.Filenames.First(f => f.EndsWith(".osu")))))
metadata = BeatmapDecoder.GetDecoder(stream).Decode(stream).Metadata;
- MemoryStream hashable = new MemoryStream();
-
- List fileInfos = new List();
-
- foreach (string file in reader.Filenames)
- {
- using (Stream s = reader.GetStream(file))
- {
- fileInfos.Add(files.Add(s, file));
- s.CopyTo(hashable);
- }
- }
-
- var overallHash = hashable.GetMd5Hash();
-
- var existing = beatmaps.Query().FirstOrDefault(b => b.Hash == overallHash);
-
- if (existing != null)
- {
- beatmaps.Populate(existing);
- Undelete(existing);
- return existing;
- }
-
- var beatmapSet = new BeatmapSetInfo
+ beatmapSet = new BeatmapSetInfo
{
OnlineBeatmapSetID = metadata.OnlineBeatmapSetID,
Beatmaps = new List(),
- Hash = overallHash,
+ Hash = hash,
Files = fileInfos,
Metadata = metadata
};