1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 05:42:56 +08:00

Add overridable method for checking local availability of current model

This commit is contained in:
Salman Ahmed 2021-01-16 22:58:29 +03:00
parent 04d17aadfa
commit 7ad8b167cc

View File

@ -47,7 +47,7 @@ namespace osu.Game.Online
{
if (modelInfo.NewValue == null)
attachDownload(null);
else if (manager?.IsAvailableLocally(modelInfo.NewValue) == true)
else if (IsModelAvailableLocally())
State.Value = DownloadState.LocallyAvailable;
else
attachDownload(Manager?.GetExistingDownload(modelInfo.NewValue));
@ -75,6 +75,13 @@ namespace osu.Game.Online
/// <param name="databasedModel">The model in database.</param>
protected virtual bool VerifyDatabasedModel([NotNull] TModel databasedModel) => true;
/// <summary>
/// Whether the given model is available in the database.
/// By default, this calls <see cref="IModelDownloader{TModel}.IsAvailableLocally"/>,
/// but can be overriden to add additional checks for verifying the model in database.
/// </summary>
protected virtual bool IsModelAvailableLocally() => Manager.IsAvailableLocally(Model.Value);
private void downloadBegan(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<TModel>>> weakRequest)
{
if (weakRequest.NewValue.TryGetTarget(out var request))