mirror of
https://github.com/ppy/osu
synced 2024-12-23 23:33:36 +00:00
Simplify download method
This commit is contained in:
parent
f2e0ced052
commit
341dc74834
@ -78,7 +78,8 @@ namespace osu.Game.Beatmaps
|
||||
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)
|
||||
{
|
||||
|
@ -42,30 +42,23 @@ namespace osu.Game.Database
|
||||
|
||||
/// <summary>
|
||||
/// 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>
|
||||
/// <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>
|
||||
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;
|
||||
|
||||
var request = CreateDownloadRequest(model, null);
|
||||
|
||||
performDownloadWithRequest(request);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Download(TModel model, params object[] extra)
|
||||
{
|
||||
if (!canDownload(model)) return false;
|
||||
|
||||
var request = CreateDownloadRequest(model, extra);
|
||||
var request = CreateDownloadRequest(model, minimiseDownloadSize);
|
||||
|
||||
performDownloadWithRequest(request);
|
||||
|
||||
|
@ -31,21 +31,12 @@ namespace osu.Game.Database
|
||||
bool IsAvailableLocally(TModel model);
|
||||
|
||||
/// <summary>
|
||||
/// Downloads a <see cref="TModel"/>.
|
||||
/// This may post notifications tracking progress.
|
||||
/// Begin a download for the requested <see cref="TModel"/>.
|
||||
/// </summary>
|
||||
/// <param name="model">The <see cref="TModel"/> to be downloaded.</param>
|
||||
/// <returns>Whether downloading can happen.</returns>
|
||||
bool Download(TModel model);
|
||||
|
||||
/// <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);
|
||||
/// <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>
|
||||
bool Download(TModel model, bool minimiseDownloadSize);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an existing <see cref="TModel"/> download request if it exists.
|
||||
|
Loading…
Reference in New Issue
Block a user