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 FileStore files;
private readonly SQLiteConnection connection;
private readonly RulesetStore rulesets; private readonly RulesetStore rulesets;
private readonly BeatmapStore beatmaps; private readonly BeatmapStore beatmaps;
@ -72,6 +74,7 @@ namespace osu.Game.Beatmaps
this.storage = storage; this.storage = storage;
this.files = files; this.files = files;
this.connection = connection;
this.rulesets = rulesets; this.rulesets = rulesets;
if (importHost != null) if (importHost != null)
@ -141,14 +144,14 @@ namespace osu.Game.Beatmaps
/// <param name="archiveReader">The beatmap to be imported.</param> /// <param name="archiveReader">The beatmap to be imported.</param>
public BeatmapSetInfo Import(ArchiveReader archiveReader) public BeatmapSetInfo Import(ArchiveReader archiveReader)
{ {
BeatmapSetInfo set = null;
// let's only allow one concurrent import at a time for now. // let's only allow one concurrent import at a time for now.
lock (importLock) lock (importLock)
{ connection.RunInTransaction(() => Import(set = importToStorage(archiveReader)));
BeatmapSetInfo set = importToStorage(archiveReader);
Import(set);
return set; return set;
} }
}
/// <summary> /// <summary>
/// Import a beatmap from a <see cref="BeatmapSetInfo"/>. /// Import a beatmap from a <see cref="BeatmapSetInfo"/>.