From 7cb87c7145129a58fd9d2102b5f27faeb30d2441 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 2 Aug 2017 14:18:35 +0900 Subject: [PATCH] Run each import in a single transaction Improves performance substantially. --- osu.Game/Beatmaps/BeatmapManager.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 105c8d9623..bbb6c975d0 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -47,6 +47,8 @@ namespace osu.Game.Beatmaps private readonly FileStore files; + private readonly SQLiteConnection connection; + private readonly RulesetStore rulesets; private readonly BeatmapStore beatmaps; @@ -72,6 +74,7 @@ namespace osu.Game.Beatmaps this.storage = storage; this.files = files; + this.connection = connection; this.rulesets = rulesets; if (importHost != null) @@ -141,13 +144,13 @@ namespace osu.Game.Beatmaps /// The beatmap to be imported. public BeatmapSetInfo Import(ArchiveReader archiveReader) { + BeatmapSetInfo set = null; + // let's only allow one concurrent import at a time for now. lock (importLock) - { - BeatmapSetInfo set = importToStorage(archiveReader); - Import(set); - return set; - } + connection.RunInTransaction(() => Import(set = importToStorage(archiveReader))); + + return set; } ///