mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Simplify download method
This commit is contained in:
@ -78,7 +78,8 @@ namespace osu.Game.Beatmaps
|
|||||||
updateQueue = new BeatmapUpdateQueue(api);
|
updateQueue = new BeatmapUpdateQueue(api);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ArchiveDownloadRequest<BeatmapSetInfo> CreateDownloadRequest(BeatmapSetInfo set, object[] options) => new DownloadBeatmapSetRequest(set, (options?.FirstOrDefault() as bool?) ?? false);
|
protected override ArchiveDownloadRequest<BeatmapSetInfo> CreateDownloadRequest(BeatmapSetInfo set, bool minimiseDownloadSize) =>
|
||||||
|
new DownloadBeatmapSetRequest(set, minimiseDownloadSize);
|
||||||
|
|
||||||
protected override Task Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive, CancellationToken cancellationToken = default)
|
protected override Task Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
|
@ -42,30 +42,23 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the download request for this <see cref="TModel"/>.
|
/// Creates the download request for this <see cref="TModel"/>.
|
||||||
/// The <paramref name="options"/> parameters will be provided when the download was initiated with extra options meant
|
|
||||||
/// to be used in the creation of the request.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model">The <see cref="TModel"/> to be downloaded.</param>
|
/// <param name="model">The <see cref="TModel"/> to be downloaded.</param>
|
||||||
/// <param name="options">Extra parameters for request creation, null if none were passed.</param>
|
/// <param name="minimiseDownloadSize">Whether this download should be optimised for slow connections. Generally means extras are not included in the download bundle..</param>
|
||||||
/// <returns>The request object.</returns>
|
/// <returns>The request object.</returns>
|
||||||
protected abstract ArchiveDownloadRequest<TModel> CreateDownloadRequest(TModel model, object[] options);
|
protected abstract ArchiveDownloadRequest<TModel> CreateDownloadRequest(TModel model, bool minimiseDownloadSize);
|
||||||
|
|
||||||
public bool Download(TModel model)
|
/// <summary>
|
||||||
|
/// Begin a download for the requested <see cref="TModel"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">The <see cref="TModel"/> to be downloaded.</param>
|
||||||
|
/// <param name="minimiseDownloadSize">Whether this download should be optimised for slow connections. Generally means extras are not included in the download bundle..</param>
|
||||||
|
/// <returns>Whether the download was started.</returns>
|
||||||
|
public bool Download(TModel model, bool minimiseDownloadSize = false)
|
||||||
{
|
{
|
||||||
if (!canDownload(model)) return false;
|
if (!canDownload(model)) return false;
|
||||||
|
|
||||||
var request = CreateDownloadRequest(model, null);
|
var request = CreateDownloadRequest(model, minimiseDownloadSize);
|
||||||
|
|
||||||
performDownloadWithRequest(request);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Download(TModel model, params object[] extra)
|
|
||||||
{
|
|
||||||
if (!canDownload(model)) return false;
|
|
||||||
|
|
||||||
var request = CreateDownloadRequest(model, extra);
|
|
||||||
|
|
||||||
performDownloadWithRequest(request);
|
performDownloadWithRequest(request);
|
||||||
|
|
||||||
|
@ -31,21 +31,12 @@ namespace osu.Game.Database
|
|||||||
bool IsAvailableLocally(TModel model);
|
bool IsAvailableLocally(TModel model);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Downloads a <see cref="TModel"/>.
|
/// Begin a download for the requested <see cref="TModel"/>.
|
||||||
/// This may post notifications tracking progress.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model">The <see cref="TModel"/> to be downloaded.</param>
|
/// <param name="model">The <see cref="TModel"/> to be downloaded.</param>
|
||||||
/// <returns>Whether downloading can happen.</returns>
|
/// <param name="minimiseDownloadSize">Whether this download should be optimised for slow connections. Generally means extras are not included in the download bundle..</param>
|
||||||
bool Download(TModel model);
|
/// <returns>Whether the download was started.</returns>
|
||||||
|
bool Download(TModel model, bool minimiseDownloadSize);
|
||||||
/// <summary>
|
|
||||||
/// Downloads a <see cref="TModel"/> with optional parameters for the download request.
|
|
||||||
/// This may post notifications tracking progress.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="model">The <see cref="TModel"/> to be downloaded.</param>
|
|
||||||
/// <param name="extra">Optional parameters to be used for creating the download request.</param>
|
|
||||||
/// <returns>Whether downloading can happen.</returns>
|
|
||||||
bool Download(TModel model, params object[] extra);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an existing <see cref="TModel"/> download request if it exists.
|
/// Gets an existing <see cref="TModel"/> download request if it exists.
|
||||||
|
Reference in New Issue
Block a user