Move second generic to abstract model downloader rather than interface type

This commit is contained in:
Dean Herbert
2021-11-05 17:37:05 +09:00
parent 99df37f32d
commit 6c385ccd29
11 changed files with 70 additions and 89 deletions

View File

@ -180,7 +180,7 @@ namespace osu.Game.Tests.Online
{ {
} }
protected override ArchiveDownloadRequest<BeatmapSetInfo> CreateDownloadRequest(BeatmapSetInfo set, bool minimiseDownloadSize) protected override ArchiveDownloadRequest<IBeatmapSetInfo> CreateDownloadRequest(IBeatmapSetInfo set, bool minimiseDownloadSize)
=> new TestDownloadRequest(set); => new TestDownloadRequest(set);
} }
@ -202,12 +202,12 @@ namespace osu.Game.Tests.Online
} }
} }
private class TestDownloadRequest : ArchiveDownloadRequest<BeatmapSetInfo> private class TestDownloadRequest : ArchiveDownloadRequest<IBeatmapSetInfo>
{ {
public new void SetProgress(float progress) => base.SetProgress(progress); public new void SetProgress(float progress) => base.SetProgress(progress);
public new void TriggerSuccess(string filename) => base.TriggerSuccess(filename); public new void TriggerSuccess(string filename) => base.TriggerSuccess(filename);
public TestDownloadRequest(BeatmapSetInfo model) public TestDownloadRequest(IBeatmapSetInfo model)
: base(model) : base(model)
{ {
} }

View File

@ -29,7 +29,7 @@ namespace osu.Game.Beatmaps
/// Handles general operations related to global beatmap management. /// Handles general operations related to global beatmap management.
/// </summary> /// </summary>
[ExcludeFromDynamicCompile] [ExcludeFromDynamicCompile]
public class BeatmapManager : IModelDownloader<BeatmapSetInfo>, IModelManager<BeatmapSetInfo>, IModelFileManager<BeatmapSetInfo, BeatmapSetFileInfo>, IModelImporter<BeatmapSetInfo>, IWorkingBeatmapCache, IDisposable public class BeatmapManager : IModelDownloader<IBeatmapSetInfo>, IModelManager<BeatmapSetInfo>, IModelFileManager<BeatmapSetInfo, BeatmapSetFileInfo>, IModelImporter<BeatmapSetInfo>, IWorkingBeatmapCache, IDisposable
{ {
private readonly BeatmapModelManager beatmapModelManager; private readonly BeatmapModelManager beatmapModelManager;
private readonly BeatmapModelDownloader beatmapModelDownloader; private readonly BeatmapModelDownloader beatmapModelDownloader;
@ -246,33 +246,16 @@ namespace osu.Game.Beatmaps
#region Implementation of IModelDownloader<BeatmapSetInfo> #region Implementation of IModelDownloader<BeatmapSetInfo>
public IBindable<WeakReference<ArchiveDownloadRequest<BeatmapSetInfo>>> DownloadBegan => beatmapModelDownloader.DownloadBegan; public IBindable<WeakReference<ArchiveDownloadRequest<IBeatmapSetInfo>>> DownloadBegan => beatmapModelDownloader.DownloadBegan;
public IBindable<WeakReference<ArchiveDownloadRequest<BeatmapSetInfo>>> DownloadFailed => beatmapModelDownloader.DownloadFailed; public IBindable<WeakReference<ArchiveDownloadRequest<IBeatmapSetInfo>>> DownloadFailed => beatmapModelDownloader.DownloadFailed;
// Temporary method until this class supports IBeatmapSetInfo or otherwise.
public bool Download(IBeatmapSetInfo model, bool minimiseDownloadSize = false) public bool Download(IBeatmapSetInfo model, bool minimiseDownloadSize = false)
{
return beatmapModelDownloader.Download(new BeatmapSetInfo
{
OnlineBeatmapSetID = model.OnlineID,
Metadata = new BeatmapMetadata
{
Title = model.Metadata?.Title ?? string.Empty,
Artist = model.Metadata?.Artist ?? string.Empty,
TitleUnicode = model.Metadata?.TitleUnicode ?? string.Empty,
ArtistUnicode = model.Metadata?.ArtistUnicode ?? string.Empty,
Author = new User { Username = model.Metadata?.Author },
}
}, minimiseDownloadSize);
}
public bool Download(BeatmapSetInfo model, bool minimiseDownloadSize = false)
{ {
return beatmapModelDownloader.Download(model, minimiseDownloadSize); return beatmapModelDownloader.Download(model, minimiseDownloadSize);
} }
public ArchiveDownloadRequest<BeatmapSetInfo> GetExistingDownload(BeatmapSetInfo model) public ArchiveDownloadRequest<IBeatmapSetInfo> GetExistingDownload(IBeatmapSetInfo model)
{ {
return beatmapModelDownloader.GetExistingDownload(model); return beatmapModelDownloader.GetExistingDownload(model);
} }

View File

@ -8,12 +8,12 @@ using osu.Game.Online.API.Requests;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
public class BeatmapModelDownloader : ModelDownloader<BeatmapSetInfo> public class BeatmapModelDownloader : ModelDownloader<BeatmapSetInfo, IBeatmapSetInfo>
{ {
protected override ArchiveDownloadRequest<BeatmapSetInfo> CreateDownloadRequest(BeatmapSetInfo set, bool minimiseDownloadSize) => protected override ArchiveDownloadRequest<IBeatmapSetInfo> CreateDownloadRequest(IBeatmapSetInfo set, bool minimiseDownloadSize) =>
new DownloadBeatmapSetRequest(set, minimiseDownloadSize); new DownloadBeatmapSetRequest(set, minimiseDownloadSize);
public override ArchiveDownloadRequest<BeatmapSetInfo> GetExistingDownload(BeatmapSetInfo model) public override ArchiveDownloadRequest<IBeatmapSetInfo> GetExistingDownload(IBeatmapSetInfo model)
=> CurrentDownloads.Find(r => r.Model.OnlineID == model.OnlineID); => CurrentDownloads.Find(r => r.Model.OnlineID == model.OnlineID);
public BeatmapModelDownloader(IModelImporter<BeatmapSetInfo> beatmapImporter, IAPIProvider api, GameHost host = null) public BeatmapModelDownloader(IModelImporter<BeatmapSetInfo> beatmapImporter, IAPIProvider api, GameHost host = null)

View File

@ -10,36 +10,35 @@ namespace osu.Game.Database
/// <summary> /// <summary>
/// Represents a <see cref="IModelManager{TModel}"/> that can download new models from an external source. /// Represents a <see cref="IModelManager{TModel}"/> that can download new models from an external source.
/// </summary> /// </summary>
/// <typeparam name="TModel">The model type.</typeparam> /// <typeparam name="T">The item's interface type.</typeparam>
/// <typeparam name="T">The model's interface type.</typeparam> public interface IModelDownloader<T> : IPostNotifications
public interface IModelDownloader<TModel, in T> : IPostNotifications where T : class
where TModel : class, T
{ {
/// <summary> /// <summary>
/// Fired when a <typeparamref name="TModel"/> download begins. /// Fired when a <typeparamref name="T"/> download begins.
/// This is NOT run on the update thread and should be scheduled. /// This is NOT run on the update thread and should be scheduled.
/// </summary> /// </summary>
IBindable<WeakReference<ArchiveDownloadRequest<TModel>>> DownloadBegan { get; } IBindable<WeakReference<ArchiveDownloadRequest<T>>> DownloadBegan { get; }
/// <summary> /// <summary>
/// Fired when a <typeparamref name="TModel"/> download is interrupted, either due to user cancellation or failure. /// Fired when a <typeparamref name="T"/> download is interrupted, either due to user cancellation or failure.
/// This is NOT run on the update thread and should be scheduled. /// This is NOT run on the update thread and should be scheduled.
/// </summary> /// </summary>
IBindable<WeakReference<ArchiveDownloadRequest<TModel>>> DownloadFailed { get; } IBindable<WeakReference<ArchiveDownloadRequest<T>>> DownloadFailed { get; }
/// <summary> /// <summary>
/// Begin a download for the requested <typeparamref name="TModel"/>. /// Begin a download for the requested <typeparamref name="T"/>.
/// </summary> /// </summary>
/// <param name="model">The <stypeparamref name="TModel"/> to be downloaded.</param> /// <param name="item">The <stypeparamref name="T"/> 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> /// <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> /// <returns>Whether the download was started.</returns>
bool Download(T model, bool minimiseDownloadSize); bool Download(T item, bool minimiseDownloadSize);
/// <summary> /// <summary>
/// Gets an existing <typeparamref name="TModel"/> download request if it exists. /// Gets an existing <typeparamref name="T"/> download request if it exists.
/// </summary> /// </summary>
/// <param name="model">The <typeparamref name="TModel"/> whose request is wanted.</param> /// <param name="item">The <typeparamref name="T"/> whose request is wanted.</param>
/// <returns>The <see cref="ArchiveDownloadRequest{TModel}"/> object if it exists, otherwise null.</returns> /// <returns>The <see cref="ArchiveDownloadRequest{T}"/> object if it exists, otherwise null.</returns>
ArchiveDownloadRequest<TModel> GetExistingDownload(TModel model); ArchiveDownloadRequest<T> GetExistingDownload(T item);
} }
} }

View File

@ -14,23 +14,24 @@ using osu.Game.Overlays.Notifications;
namespace osu.Game.Database namespace osu.Game.Database
{ {
public abstract class ModelDownloader<TModel> : IModelDownloader<TModel> public abstract class ModelDownloader<TModel, T> : IModelDownloader<T>
where TModel : class, IHasPrimaryKey, ISoftDelete, IEquatable<TModel> where TModel : class, IHasPrimaryKey, ISoftDelete, IEquatable<TModel>, T
where T : class
{ {
public Action<Notification> PostNotification { protected get; set; } public Action<Notification> PostNotification { protected get; set; }
public IBindable<WeakReference<ArchiveDownloadRequest<TModel>>> DownloadBegan => downloadBegan; public IBindable<WeakReference<ArchiveDownloadRequest<T>>> DownloadBegan => downloadBegan;
private readonly Bindable<WeakReference<ArchiveDownloadRequest<TModel>>> downloadBegan = new Bindable<WeakReference<ArchiveDownloadRequest<TModel>>>(); private readonly Bindable<WeakReference<ArchiveDownloadRequest<T>>> downloadBegan = new Bindable<WeakReference<ArchiveDownloadRequest<T>>>();
public IBindable<WeakReference<ArchiveDownloadRequest<TModel>>> DownloadFailed => downloadFailed; public IBindable<WeakReference<ArchiveDownloadRequest<T>>> DownloadFailed => downloadFailed;
private readonly Bindable<WeakReference<ArchiveDownloadRequest<TModel>>> downloadFailed = new Bindable<WeakReference<ArchiveDownloadRequest<TModel>>>(); private readonly Bindable<WeakReference<ArchiveDownloadRequest<T>>> downloadFailed = new Bindable<WeakReference<ArchiveDownloadRequest<T>>>();
private readonly IModelImporter<TModel> importer; private readonly IModelImporter<TModel> importer;
private readonly IAPIProvider api; private readonly IAPIProvider api;
protected readonly List<ArchiveDownloadRequest<TModel>> CurrentDownloads = new List<ArchiveDownloadRequest<TModel>>(); protected readonly List<ArchiveDownloadRequest<T>> CurrentDownloads = new List<ArchiveDownloadRequest<T>>();
protected ModelDownloader(IModelImporter<TModel> importer, IAPIProvider api, IIpcHost importHost = null) protected ModelDownloader(IModelImporter<TModel> importer, IAPIProvider api, IIpcHost importHost = null)
{ {
@ -39,14 +40,14 @@ namespace osu.Game.Database
} }
/// <summary> /// <summary>
/// Creates the download request for this <typeparamref name="TModel"/>. /// Creates the download request for this <typeparamref name="T"/>.
/// </summary> /// </summary>
/// <param name="model">The <typeparamref name="TModel"/> to be downloaded.</param> /// <param name="model">The <typeparamref name="T"/> 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> /// <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, bool minimiseDownloadSize); protected abstract ArchiveDownloadRequest<T> CreateDownloadRequest(T model, bool minimiseDownloadSize);
public bool Download(TModel model, bool minimiseDownloadSize = false) public bool Download(T model, bool minimiseDownloadSize = false)
{ {
if (!canDownload(model)) return false; if (!canDownload(model)) return false;
@ -72,7 +73,7 @@ namespace osu.Game.Database
// for now a failed import will be marked as a failed download for simplicity. // for now a failed import will be marked as a failed download for simplicity.
if (!imported.Any()) if (!imported.Any())
downloadFailed.Value = new WeakReference<ArchiveDownloadRequest<TModel>>(request); downloadFailed.Value = new WeakReference<ArchiveDownloadRequest<T>>(request);
CurrentDownloads.Remove(request); CurrentDownloads.Remove(request);
}, TaskCreationOptions.LongRunning); }, TaskCreationOptions.LongRunning);
@ -91,14 +92,14 @@ namespace osu.Game.Database
api.PerformAsync(request); api.PerformAsync(request);
downloadBegan.Value = new WeakReference<ArchiveDownloadRequest<TModel>>(request); downloadBegan.Value = new WeakReference<ArchiveDownloadRequest<T>>(request);
return true; return true;
void triggerFailure(Exception error) void triggerFailure(Exception error)
{ {
CurrentDownloads.Remove(request); CurrentDownloads.Remove(request);
downloadFailed.Value = new WeakReference<ArchiveDownloadRequest<TModel>>(request); downloadFailed.Value = new WeakReference<ArchiveDownloadRequest<T>>(request);
notification.State = ProgressNotificationState.Cancelled; notification.State = ProgressNotificationState.Cancelled;
@ -107,9 +108,9 @@ namespace osu.Game.Database
} }
} }
public abstract ArchiveDownloadRequest<TModel> GetExistingDownload(TModel model); public abstract ArchiveDownloadRequest<T> GetExistingDownload(T model);
private bool canDownload(TModel model) => GetExistingDownload(model) == null && api != null; private bool canDownload(T model) => GetExistingDownload(model) == null && api != null;
private class DownloadNotification : ProgressNotification private class DownloadNotification : ProgressNotification
{ {

View File

@ -6,11 +6,11 @@ using osu.Game.Beatmaps;
namespace osu.Game.Online.API.Requests namespace osu.Game.Online.API.Requests
{ {
public class DownloadBeatmapSetRequest : ArchiveDownloadRequest<BeatmapSetInfo> public class DownloadBeatmapSetRequest : ArchiveDownloadRequest<IBeatmapSetInfo>
{ {
private readonly bool noVideo; private readonly bool noVideo;
public DownloadBeatmapSetRequest(BeatmapSetInfo set, bool noVideo) public DownloadBeatmapSetRequest(IBeatmapSetInfo set, bool noVideo)
: base(set) : base(set)
{ {
this.noVideo = noVideo; this.noVideo = noVideo;
@ -25,6 +25,6 @@ namespace osu.Game.Online.API.Requests
protected override string FileExtension => ".osz"; protected override string FileExtension => ".osz";
protected override string Target => $@"beatmapsets/{Model.OnlineBeatmapSetID}/download{(noVideo ? "?noVideo=1" : "")}"; protected override string Target => $@"beatmapsets/{Model.OnlineID}/download{(noVideo ? "?noVideo=1" : "")}";
} }
} }

View File

@ -5,15 +5,15 @@ using osu.Game.Scoring;
namespace osu.Game.Online.API.Requests namespace osu.Game.Online.API.Requests
{ {
public class DownloadReplayRequest : ArchiveDownloadRequest<ScoreInfo> public class DownloadReplayRequest : ArchiveDownloadRequest<IScoreInfo>
{ {
public DownloadReplayRequest(ScoreInfo score) public DownloadReplayRequest(IScoreInfo score)
: base(score) : base(score)
{ {
} }
protected override string FileExtension => ".osr"; protected override string FileExtension => ".osr";
protected override string Target => $@"scores/{Model.Ruleset.ShortName}/{Model.OnlineScoreID}/download"; protected override string Target => $@"scores/{Model.Ruleset.ShortName}/{Model.OnlineID}/download";
} }
} }

View File

@ -16,7 +16,7 @@ namespace osu.Game.Online
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
protected BeatmapManager? Manager { get; private set; } protected BeatmapManager? Manager { get; private set; }
private ArchiveDownloadRequest<BeatmapSetInfo>? attachedRequest; private ArchiveDownloadRequest<IBeatmapSetInfo>? attachedRequest;
public BeatmapDownloadTracker(IBeatmapSetInfo trackedItem) public BeatmapDownloadTracker(IBeatmapSetInfo trackedItem)
: base(trackedItem) : base(trackedItem)
@ -25,8 +25,8 @@ namespace osu.Game.Online
private IBindable<WeakReference<BeatmapSetInfo>>? managerUpdated; private IBindable<WeakReference<BeatmapSetInfo>>? managerUpdated;
private IBindable<WeakReference<BeatmapSetInfo>>? managerRemoved; private IBindable<WeakReference<BeatmapSetInfo>>? managerRemoved;
private IBindable<WeakReference<ArchiveDownloadRequest<BeatmapSetInfo>>>? managerDownloadBegan; private IBindable<WeakReference<ArchiveDownloadRequest<IBeatmapSetInfo>>>? managerDownloadBegan;
private IBindable<WeakReference<ArchiveDownloadRequest<BeatmapSetInfo>>>? managerDownloadFailed; private IBindable<WeakReference<ArchiveDownloadRequest<IBeatmapSetInfo>>>? managerDownloadFailed;
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load() private void load()
@ -52,7 +52,7 @@ namespace osu.Game.Online
managerRemoved.BindValueChanged(itemRemoved); managerRemoved.BindValueChanged(itemRemoved);
} }
private void downloadBegan(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<BeatmapSetInfo>>> weakRequest) private void downloadBegan(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<IBeatmapSetInfo>>> weakRequest)
{ {
if (weakRequest.NewValue.TryGetTarget(out var request)) if (weakRequest.NewValue.TryGetTarget(out var request))
{ {
@ -64,7 +64,7 @@ namespace osu.Game.Online
} }
} }
private void downloadFailed(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<BeatmapSetInfo>>> weakRequest) private void downloadFailed(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<IBeatmapSetInfo>>> weakRequest)
{ {
if (weakRequest.NewValue.TryGetTarget(out var request)) if (weakRequest.NewValue.TryGetTarget(out var request))
{ {
@ -76,7 +76,7 @@ namespace osu.Game.Online
} }
} }
private void attachDownload(ArchiveDownloadRequest<BeatmapSetInfo>? request) private void attachDownload(ArchiveDownloadRequest<IBeatmapSetInfo>? request)
{ {
if (attachedRequest != null) if (attachedRequest != null)
{ {

View File

@ -16,7 +16,7 @@ namespace osu.Game.Online
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
protected ScoreManager? Manager { get; private set; } protected ScoreManager? Manager { get; private set; }
private ArchiveDownloadRequest<ScoreInfo>? attachedRequest; private ArchiveDownloadRequest<IScoreInfo>? attachedRequest;
public ScoreDownloadTracker(ScoreInfo trackedItem) public ScoreDownloadTracker(ScoreInfo trackedItem)
: base(trackedItem) : base(trackedItem)
@ -25,8 +25,8 @@ namespace osu.Game.Online
private IBindable<WeakReference<ScoreInfo>>? managerUpdated; private IBindable<WeakReference<ScoreInfo>>? managerUpdated;
private IBindable<WeakReference<ScoreInfo>>? managerRemoved; private IBindable<WeakReference<ScoreInfo>>? managerRemoved;
private IBindable<WeakReference<ArchiveDownloadRequest<ScoreInfo>>>? managerDownloadBegan; private IBindable<WeakReference<ArchiveDownloadRequest<IScoreInfo>>>? managerDownloadBegan;
private IBindable<WeakReference<ArchiveDownloadRequest<ScoreInfo>>>? managerDownloadFailed; private IBindable<WeakReference<ArchiveDownloadRequest<IScoreInfo>>>? managerDownloadFailed;
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load() private void load()
@ -56,7 +56,7 @@ namespace osu.Game.Online
managerRemoved.BindValueChanged(itemRemoved); managerRemoved.BindValueChanged(itemRemoved);
} }
private void downloadBegan(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<ScoreInfo>>> weakRequest) private void downloadBegan(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<IScoreInfo>>> weakRequest)
{ {
if (weakRequest.NewValue.TryGetTarget(out var request)) if (weakRequest.NewValue.TryGetTarget(out var request))
{ {
@ -68,7 +68,7 @@ namespace osu.Game.Online
} }
} }
private void downloadFailed(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<ScoreInfo>>> weakRequest) private void downloadFailed(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<IScoreInfo>>> weakRequest)
{ {
if (weakRequest.NewValue.TryGetTarget(out var request)) if (weakRequest.NewValue.TryGetTarget(out var request))
{ {
@ -80,7 +80,7 @@ namespace osu.Game.Online
} }
} }
private void attachDownload(ArchiveDownloadRequest<ScoreInfo>? request) private void attachDownload(ArchiveDownloadRequest<IScoreInfo>? request)
{ {
if (attachedRequest != null) if (attachedRequest != null)
{ {
@ -144,7 +144,7 @@ namespace osu.Game.Online
} }
} }
private bool checkEquality(ScoreInfo x, ScoreInfo y) => x.OnlineScoreID == y.OnlineScoreID; private bool checkEquality(IScoreInfo x, IScoreInfo y) => x.OnlineID == y.OnlineID;
#region Disposal #region Disposal

View File

@ -25,7 +25,7 @@ using osu.Game.Rulesets.Scoring;
namespace osu.Game.Scoring namespace osu.Game.Scoring
{ {
public class ScoreManager : IModelManager<ScoreInfo>, IModelImporter<ScoreInfo>, IModelFileManager<ScoreInfo, ScoreFileInfo>, IModelDownloader<ScoreInfo> public class ScoreManager : IModelManager<ScoreInfo>, IModelImporter<ScoreInfo>, IModelFileManager<ScoreInfo, ScoreFileInfo>, IModelDownloader<IScoreInfo>
{ {
private readonly Scheduler scheduler; private readonly Scheduler scheduler;
private readonly Func<BeatmapDifficultyCache> difficulties; private readonly Func<BeatmapDifficultyCache> difficulties;
@ -350,16 +350,14 @@ namespace osu.Game.Scoring
#region Implementation of IModelDownloader<ScoreInfo> #region Implementation of IModelDownloader<ScoreInfo>
public IBindable<WeakReference<ArchiveDownloadRequest<ScoreInfo>>> DownloadBegan => scoreModelDownloader.DownloadBegan; public IBindable<WeakReference<ArchiveDownloadRequest<IScoreInfo>>> DownloadBegan => scoreModelDownloader.DownloadBegan;
public IBindable<WeakReference<ArchiveDownloadRequest<ScoreInfo>>> DownloadFailed => scoreModelDownloader.DownloadFailed; public IBindable<WeakReference<ArchiveDownloadRequest<IScoreInfo>>> DownloadFailed => scoreModelDownloader.DownloadFailed;
public bool Download(ScoreInfo model, bool minimiseDownloadSize) public bool Download(IScoreInfo model, bool minimiseDownloadSize) =>
{ scoreModelDownloader.Download(model, minimiseDownloadSize);
return scoreModelDownloader.Download(model, minimiseDownloadSize);
}
public ArchiveDownloadRequest<ScoreInfo> GetExistingDownload(ScoreInfo model) public ArchiveDownloadRequest<IScoreInfo> GetExistingDownload(IScoreInfo model)
{ {
return scoreModelDownloader.GetExistingDownload(model); return scoreModelDownloader.GetExistingDownload(model);
} }

View File

@ -8,16 +8,16 @@ using osu.Game.Online.API.Requests;
namespace osu.Game.Scoring namespace osu.Game.Scoring
{ {
public class ScoreModelDownloader : ModelDownloader<ScoreInfo> public class ScoreModelDownloader : ModelDownloader<ScoreInfo, IScoreInfo>
{ {
public ScoreModelDownloader(IModelImporter<ScoreInfo> scoreManager, IAPIProvider api, IIpcHost importHost = null) public ScoreModelDownloader(IModelImporter<ScoreInfo> scoreManager, IAPIProvider api, IIpcHost importHost = null)
: base(scoreManager, api, importHost) : base(scoreManager, api, importHost)
{ {
} }
protected override ArchiveDownloadRequest<ScoreInfo> CreateDownloadRequest(ScoreInfo score, bool minimiseDownload) => new DownloadReplayRequest(score); protected override ArchiveDownloadRequest<IScoreInfo> CreateDownloadRequest(IScoreInfo score, bool minimiseDownload) => new DownloadReplayRequest(score);
public override ArchiveDownloadRequest<ScoreInfo> GetExistingDownload(ScoreInfo model) public override ArchiveDownloadRequest<IScoreInfo> GetExistingDownload(IScoreInfo model)
=> CurrentDownloads.Find(r => r.Model.OnlineScoreID == model.OnlineScoreID); => CurrentDownloads.Find(r => r.Model.OnlineID == model.OnlineID);
} }
} }