1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 11:27:24 +08:00

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,13 +144,13 @@ 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);
return set;
}
connection.RunInTransaction(() => Import(set = importToStorage(archiveReader)));
return set;
}
/// <summary>