mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 02:02:53 +08:00
Hand off comparison logic for database query to implementors
Equals overrides are not used in EF queries without running the comaprison locally instead of on the database, so to preserve that the comparison logic is instead implemented on a per manager basis.
This commit is contained in:
parent
72bb6f8c12
commit
61260cf599
@ -145,6 +145,8 @@ namespace osu.Game.Beatmaps
|
||||
void resetIds() => beatmapSet.Beatmaps.ForEach(b => b.OnlineBeatmapID = null);
|
||||
}
|
||||
|
||||
protected override bool CheckLocalAvailability(BeatmapSetInfo model, IQueryable<BeatmapSetInfo> items) => items.Any(b => b.OnlineBeatmapSetID == model.OnlineBeatmapSetID);
|
||||
|
||||
/// <summary>
|
||||
/// Delete a beatmap difficulty.
|
||||
/// </summary>
|
||||
|
@ -110,7 +110,15 @@ namespace osu.Game.Database
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool IsAvailableLocally(TModel model) => modelStore.ConsumableItems.Any(m => m.Equals(model) && !m.DeletePending);
|
||||
public bool IsAvailableLocally(TModel model) => CheckLocalAvailability(model, modelStore.ConsumableItems.Where(m => !m.DeletePending));
|
||||
|
||||
/// <summary>
|
||||
/// Performs implementation specific comparisons to determine whether a given model is present in the local store.
|
||||
/// </summary>
|
||||
/// <param name="model">The <see cref="TModel"/> whose existence needs to be checked.</param>
|
||||
/// <param name="items">The usable items present in the store.</param>
|
||||
/// <returns>Whether the <see cref="TModel"/> exists.</returns>
|
||||
protected abstract bool CheckLocalAvailability(TModel model, IQueryable<TModel> items);
|
||||
|
||||
public ArchiveDownloadRequest<TModel> GetExistingDownload(TModel model) => currentDownloads.Find(r => r.Model.Equals(model));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user