Simplify download method

This commit is contained in:
Dean Herbert
2019-06-19 01:41:19 +09:00
parent f2e0ced052
commit 341dc74834
3 changed files with 16 additions and 31 deletions

View File

@ -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);