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

Merge branch 'master' into model-downloader-split

This commit is contained in:
Dan Balasescu 2021-10-01 22:34:39 +09:00 committed by GitHub
commit 6a172d54d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 10 deletions

View File

@ -29,12 +29,13 @@ namespace osu.Game.Beatmaps
/// Handles general operations related to global beatmap management.
/// </summary>
[ExcludeFromDynamicCompile]
public class BeatmapManager : IModelDownloader<BeatmapSetInfo>, IModelManager<BeatmapSetInfo>, IModelFileManager<BeatmapSetInfo, BeatmapSetFileInfo>, ICanAcceptFiles, IWorkingBeatmapCache
public class BeatmapManager : IModelDownloader<BeatmapSetInfo>, IModelManager<BeatmapSetInfo>, IModelFileManager<BeatmapSetInfo, BeatmapSetFileInfo>, ICanAcceptFiles, IWorkingBeatmapCache, IDisposable
{
private readonly BeatmapModelManager beatmapModelManager;
private readonly BeatmapModelDownloader beatmapModelDownloader;
private readonly WorkingBeatmapCache workingBeatmapCache;
private readonly BeatmapOnlineLookupQueue onlineBetamapLookupQueue;
public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore<byte[]> resources, GameHost host = null,
WorkingBeatmap defaultBeatmap = null, bool performOnlineLookups = false)
@ -47,8 +48,8 @@ namespace osu.Game.Beatmaps
if (performOnlineLookups)
{
var onlineBeatmapLookupCache = new BeatmapOnlineLookupQueue(api, storage);
beatmapModelManager.PopulateOnlineInformation = onlineBeatmapLookupCache.UpdateAsync;
onlineBetamapLookupQueue = new BeatmapOnlineLookupQueue(api, storage);
beatmapModelManager.OnlineLookupQueue = onlineBetamapLookupQueue;
}
}
@ -323,5 +324,14 @@ namespace osu.Game.Beatmaps
}
#endregion
#region Implementation of IDisposable
public void Dispose()
{
onlineBetamapLookupQueue?.Dispose();
}
#endregion
}
}

View File

@ -47,10 +47,9 @@ namespace osu.Game.Beatmaps
public IBindable<WeakReference<BeatmapInfo>> BeatmapRestored => beatmapRestored;
/// <summary>
/// A function which populates online information during the import process.
/// It is run as the final step of import.
/// An online lookup queue component which handles populating online beatmap metadata.
/// </summary>
public Func<BeatmapSetInfo, CancellationToken, Task> PopulateOnlineInformation;
public BeatmapOnlineLookupQueue OnlineLookupQueue { private get; set; }
/// <summary>
/// The game working beatmap cache, used to invalidate entries on changes.
@ -102,8 +101,8 @@ namespace osu.Game.Beatmaps
bool hadOnlineBeatmapIDs = beatmapSet.Beatmaps.Any(b => b.OnlineBeatmapID > 0);
if (PopulateOnlineInformation != null)
await PopulateOnlineInformation(beatmapSet, cancellationToken).ConfigureAwait(false);
if (OnlineLookupQueue != null)
await OnlineLookupQueue.UpdateAsync(beatmapSet, cancellationToken).ConfigureAwait(false);
// ensure at least one beatmap was able to retrieve or keep an online ID, else drop the set ID.
if (hadOnlineBeatmapIDs && !beatmapSet.Beatmaps.Any(b => b.OnlineBeatmapID > 0))

View File

@ -25,7 +25,7 @@ namespace osu.Game.Beatmaps
/// A component which handles population of online IDs for beatmaps using a two part lookup procedure.
/// </summary>
/// <remarks>
/// On creating the component, a copy of a database containing metadata for a large subset of beatmaps (stored to <see cref="cache_database_name"/>).
/// On creating the component, a copy of a database containing metadata for a large subset of beatmaps (stored to <see cref="cache_database_name"/>) will be downloaded if not already present locally.
/// This will always be checked before doing a second online query to get required metadata.
/// </remarks>
[ExcludeFromDynamicCompile]
@ -211,7 +211,7 @@ namespace osu.Game.Beatmaps
}
private void logForModel(BeatmapSetInfo set, string message) =>
ArchiveModelManager<BeatmapSetInfo, BeatmapSetFileInfo>.LogForModel(set, $"{nameof(BeatmapOnlineLookupQueue)}] {message}");
ArchiveModelManager<BeatmapSetInfo, BeatmapSetFileInfo>.LogForModel(set, $"[{nameof(BeatmapOnlineLookupQueue)}] {message}");
public void Dispose()
{

View File

@ -524,6 +524,7 @@ namespace osu.Game
base.Dispose(isDisposing);
RulesetStore?.Dispose();
BeatmapManager?.Dispose();
LocalConfig?.Dispose();
contextFactory?.FlushConnections();