From 56e8c7303ce402400f87b6b42c66f9477b02272c Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Sun, 15 Oct 2017 21:56:33 +0300 Subject: [PATCH] Revert "Fix inconsistent lock usage in BeatmapManager" This reverts commit 4a064da30f6349a7d2f327aa2b2769635fe02037. --- .../Beatmaps/IO/ImportBeatmapTest.cs | 3 +-- osu.Game/Beatmaps/BeatmapManager.cs | 26 +++++++------------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index cd9e765e7f..f2ab00bead 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -138,9 +138,8 @@ private void ensureLoaded(OsuGameBase osu, int timeout = 60000) var set = queryBeatmapSets().First(); foreach (BeatmapInfo b in set.Beatmaps) - Assert.IsTrue(set.Beatmaps.Any(c => c.OnlineBeatmapID == b.OnlineBeatmapID)); - Assert.IsTrue(set.Beatmaps.Count > 0); + Assert.IsTrue(set.Beatmaps.Count > 0); var beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 0))?.Beatmap; Assert.IsTrue(beatmap?.HitObjects.Count > 0); diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 30da9ceae9..d364a8fbe4 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -59,6 +59,8 @@ public class BeatmapManager private readonly FileStore files; + private readonly OsuDbContext connection; + private readonly RulesetStore rulesets; private readonly BeatmapStore beatmaps; @@ -90,6 +92,7 @@ public BeatmapManager(Storage storage, FileStore files, OsuDbContext connection, this.storage = storage; this.files = files; + this.connection = connection; this.rulesets = rulesets; this.api = api; @@ -160,7 +163,7 @@ public void Import(params string[] paths) /// The beatmap to be imported. public BeatmapSetInfo Import(ArchiveReader archiveReader) { - BeatmapSetInfo set; + BeatmapSetInfo set = null; // let's only allow one concurrent import at a time for now. lock (importLock) @@ -178,8 +181,7 @@ public void Import(BeatmapSetInfo beatmapSetInfo) // If we have an ID then we already exist in the database. if (beatmapSetInfo.ID != 0) return; - lock (beatmaps) - beatmaps.Add(beatmapSetInfo); + beatmaps.Add(beatmapSetInfo); } /// @@ -270,21 +272,13 @@ public void Delete(BeatmapSetInfo beatmapSet) /// Delete a beatmap difficulty. /// /// The beatmap difficulty to hide. - public void Hide(BeatmapInfo beatmap) - { - lock (beatmaps) - beatmaps.Hide(beatmap); - } + public void Hide(BeatmapInfo beatmap) => beatmaps.Hide(beatmap); /// /// Restore a beatmap difficulty. /// /// The beatmap difficulty to restore. - public void Restore(BeatmapInfo beatmap) - { - lock (beatmaps) - beatmaps.Restore(beatmap); - } + public void Restore(BeatmapInfo beatmap) => beatmaps.Restore(beatmap); /// /// Returns a to a usable state if it has previously been deleted but not yet purged. @@ -293,8 +287,7 @@ public void Restore(BeatmapInfo beatmap) /// The beatmap to restore. public void Undelete(BeatmapSetInfo beatmapSet) { - lock (beatmaps) - if (!beatmaps.Undelete(beatmapSet)) return; + if (!beatmaps.Undelete(beatmapSet)) return; if (!beatmapSet.Protected) files.Reference(beatmapSet.Files.Select(f => f.FileInfo).ToArray()); @@ -368,8 +361,7 @@ public BeatmapSetInfo QueryBeatmapSet(Func query) /// Results from the provided query. public List QueryBeatmapSets(Func query) { - lock (beatmaps) - return beatmaps.QueryAndPopulate(query); + return beatmaps.QueryAndPopulate(query); } ///