Run each import in a single transaction

Improves performance substantially.
This commit is contained in:
Dean Herbert 2017-08-02 14:18:35 +09:00
parent 6eb960010f
commit 7cb87c7145

View File

@ -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,14 +144,14 @@ namespace osu.Game.Beatmaps
/// <param name="archiveReader">The beatmap to be imported.</param>
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);
connection.RunInTransaction(() => Import(set = importToStorage(archiveReader)));
return set;
}
}
/// <summary>
/// Import a beatmap from a <see cref="BeatmapSetInfo"/>.