mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Don't block imports and BeatmapStore operations using the same lock
This commit is contained in:
@ -102,6 +102,8 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private object ImportLock = new object();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Import a beatmap from an <see cref="ArchiveReader"/>.
|
/// Import a beatmap from an <see cref="ArchiveReader"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -109,7 +111,7 @@ namespace osu.Game.Beatmaps
|
|||||||
public BeatmapSetInfo Import(ArchiveReader archiveReader)
|
public BeatmapSetInfo Import(ArchiveReader archiveReader)
|
||||||
{
|
{
|
||||||
// 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 (this)
|
lock (ImportLock)
|
||||||
{
|
{
|
||||||
BeatmapSetInfo set = importToStorage(archiveReader);
|
BeatmapSetInfo set = importToStorage(archiveReader);
|
||||||
Import(set);
|
Import(set);
|
||||||
@ -126,6 +128,7 @@ namespace osu.Game.Beatmaps
|
|||||||
// If we have an ID then we already exist in the database.
|
// If we have an ID then we already exist in the database.
|
||||||
if (beatmapSetInfo.ID != 0) return;
|
if (beatmapSetInfo.ID != 0) return;
|
||||||
|
|
||||||
|
lock (beatmaps)
|
||||||
beatmaps.Add(beatmapSetInfo);
|
beatmaps.Add(beatmapSetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,14 +139,12 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <param name="beatmapSet">The beatmap to delete.</param>
|
/// <param name="beatmapSet">The beatmap to delete.</param>
|
||||||
public void Delete(BeatmapSetInfo beatmapSet)
|
public void Delete(BeatmapSetInfo beatmapSet)
|
||||||
{
|
{
|
||||||
lock (this)
|
lock (beatmaps)
|
||||||
{
|
|
||||||
if (!beatmaps.Delete(beatmapSet)) return;
|
if (!beatmaps.Delete(beatmapSet)) return;
|
||||||
|
|
||||||
if (!beatmapSet.Protected)
|
if (!beatmapSet.Protected)
|
||||||
files.Dereference(beatmapSet.Files);
|
files.Dereference(beatmapSet.Files);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a <see cref="BeatmapSetInfo"/> to a usable state if it has previously been deleted but not yet purged.
|
/// Returns a <see cref="BeatmapSetInfo"/> to a usable state if it has previously been deleted but not yet purged.
|
||||||
@ -152,13 +153,11 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <param name="beatmapSet">The beatmap to restore.</param>
|
/// <param name="beatmapSet">The beatmap to restore.</param>
|
||||||
public void Undelete(BeatmapSetInfo beatmapSet)
|
public void Undelete(BeatmapSetInfo beatmapSet)
|
||||||
{
|
{
|
||||||
lock (this)
|
lock (beatmaps)
|
||||||
{
|
|
||||||
if (!beatmaps.Undelete(beatmapSet)) return;
|
if (!beatmaps.Undelete(beatmapSet)) return;
|
||||||
|
|
||||||
files.Reference(beatmapSet.Files);
|
files.Reference(beatmapSet.Files);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve a <see cref="WorkingBeatmap"/> instance for the provided <see cref="BeatmapInfo"/>
|
/// Retrieve a <see cref="WorkingBeatmap"/> instance for the provided <see cref="BeatmapInfo"/>
|
||||||
@ -167,12 +166,11 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <param name="previous">The currently loaded <see cref="WorkingBeatmap"/>. Allows for optimisation where elements are shared with the new beatmap.</param>
|
/// <param name="previous">The currently loaded <see cref="WorkingBeatmap"/>. Allows for optimisation where elements are shared with the new beatmap.</param>
|
||||||
/// <returns>A <see cref="WorkingBeatmap"/> instance correlating to the provided <see cref="BeatmapInfo"/>.</returns>
|
/// <returns>A <see cref="WorkingBeatmap"/> instance correlating to the provided <see cref="BeatmapInfo"/>.</returns>
|
||||||
public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null)
|
public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null)
|
||||||
{
|
|
||||||
lock (this)
|
|
||||||
{
|
{
|
||||||
if (beatmapInfo == null || beatmapInfo == DefaultBeatmap?.BeatmapInfo)
|
if (beatmapInfo == null || beatmapInfo == DefaultBeatmap?.BeatmapInfo)
|
||||||
return DefaultBeatmap;
|
return DefaultBeatmap;
|
||||||
|
|
||||||
|
lock (beatmaps)
|
||||||
beatmaps.Populate(beatmapInfo);
|
beatmaps.Populate(beatmapInfo);
|
||||||
|
|
||||||
if (beatmapInfo.BeatmapSet == null)
|
if (beatmapInfo.BeatmapSet == null)
|
||||||
@ -187,7 +185,6 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
return working;
|
return working;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the manager to an empty state.
|
/// Reset the manager to an empty state.
|
||||||
|
Reference in New Issue
Block a user