mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Fix incorrect DI fetch and apply nullability to ModelDownloader
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -19,18 +17,18 @@ namespace osu.Game.Database
|
||||
where TModel : class, IHasGuidPrimaryKey, ISoftDelete, IEquatable<TModel>, T
|
||||
where T : class
|
||||
{
|
||||
public Action<Notification> PostNotification { protected get; set; }
|
||||
public Action<Notification>? PostNotification { protected get; set; }
|
||||
|
||||
public event Action<ArchiveDownloadRequest<T>> DownloadBegan;
|
||||
public event Action<ArchiveDownloadRequest<T>>? DownloadBegan;
|
||||
|
||||
public event Action<ArchiveDownloadRequest<T>> DownloadFailed;
|
||||
public event Action<ArchiveDownloadRequest<T>>? DownloadFailed;
|
||||
|
||||
private readonly IModelImporter<TModel> importer;
|
||||
private readonly IAPIProvider api;
|
||||
private readonly IAPIProvider? api;
|
||||
|
||||
protected readonly List<ArchiveDownloadRequest<T>> CurrentDownloads = new List<ArchiveDownloadRequest<T>>();
|
||||
|
||||
protected ModelDownloader(IModelImporter<TModel> importer, IAPIProvider api)
|
||||
protected ModelDownloader(IModelImporter<TModel> importer, IAPIProvider? api)
|
||||
{
|
||||
this.importer = importer;
|
||||
this.api = api;
|
||||
@ -87,7 +85,7 @@ namespace osu.Game.Database
|
||||
CurrentDownloads.Add(request);
|
||||
PostNotification?.Invoke(notification);
|
||||
|
||||
api.PerformAsync(request);
|
||||
api?.PerformAsync(request);
|
||||
|
||||
DownloadBegan?.Invoke(request);
|
||||
return true;
|
||||
@ -101,11 +99,11 @@ namespace osu.Game.Database
|
||||
notification.State = ProgressNotificationState.Cancelled;
|
||||
|
||||
if (!(error is OperationCanceledException))
|
||||
Logger.Error(error, $"{importer?.HumanisedModelName.Titleize()} download failed!");
|
||||
Logger.Error(error, $"{importer.HumanisedModelName.Titleize()} download failed!");
|
||||
}
|
||||
}
|
||||
|
||||
public abstract ArchiveDownloadRequest<T> GetExistingDownload(T model);
|
||||
public abstract ArchiveDownloadRequest<T>? GetExistingDownload(T model);
|
||||
|
||||
private bool canDownload(T model) => GetExistingDownload(model) == null && api != null;
|
||||
|
||||
|
Reference in New Issue
Block a user