mirror of https://github.com/ppy/osu
Add method to check if model exists locally already
This commit is contained in:
parent
709ca03a08
commit
f4dab4da85
|
@ -7,6 +7,7 @@
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace osu.Game.Database
|
namespace osu.Game.Database
|
||||||
|
@ -37,10 +38,13 @@ public abstract class ArchiveDownloadModelManager<TModel, TFileModel, TDownloadR
|
||||||
|
|
||||||
private readonly List<TDownloadRequestModel> currentDownloads = new List<TDownloadRequestModel>();
|
private readonly List<TDownloadRequestModel> currentDownloads = new List<TDownloadRequestModel>();
|
||||||
|
|
||||||
|
private readonly MutableDatabaseBackedStoreWithFileIncludes<TModel, TFileModel> modelStore;
|
||||||
|
|
||||||
protected ArchiveDownloadModelManager(Storage storage, IDatabaseContextFactory contextFactory, IAPIProvider api, MutableDatabaseBackedStoreWithFileIncludes<TModel, TFileModel> modelStore, IIpcHost importHost = null)
|
protected ArchiveDownloadModelManager(Storage storage, IDatabaseContextFactory contextFactory, IAPIProvider api, MutableDatabaseBackedStoreWithFileIncludes<TModel, TFileModel> modelStore, IIpcHost importHost = null)
|
||||||
: base(storage, contextFactory, modelStore, importHost)
|
: base(storage, contextFactory, modelStore, importHost)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
|
this.modelStore = modelStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -70,6 +74,13 @@ public bool Download(TModel model)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks whether a given <see cref="TModel"/> is available in the local store already.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">The <see cref="TModel"/> whose existence needs to be checked.</param>
|
||||||
|
/// <returns>Whether the <see cref="TModel"/> exists locally.</returns>
|
||||||
|
public bool IsAvailableLocally(TModel model) => modelStore.ConsumableItems.Any(m => m.Equals(model));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Downloads a <see cref="TModel"/> with optional parameters for the download request.
|
/// Downloads a <see cref="TModel"/> with optional parameters for the download request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue