mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Remove redundant variable, handle all request failures
This commit is contained in:
@ -94,16 +94,7 @@ namespace osu.Game.Database
|
|||||||
}, TaskCreationOptions.LongRunning);
|
}, TaskCreationOptions.LongRunning);
|
||||||
};
|
};
|
||||||
|
|
||||||
request.Failure += error =>
|
request.Failure += error => handleRequestFailure(request, notification, error);
|
||||||
{
|
|
||||||
DownloadFailed?.Invoke(request);
|
|
||||||
|
|
||||||
if (error is OperationCanceledException) return;
|
|
||||||
|
|
||||||
notification.State = ProgressNotificationState.Cancelled;
|
|
||||||
Logger.Error(error, $"{HumanisedModelName.Titleize()} download failed!");
|
|
||||||
currentDownloads.Remove(request);
|
|
||||||
};
|
|
||||||
|
|
||||||
notification.CancelRequested += () =>
|
notification.CancelRequested += () =>
|
||||||
{
|
{
|
||||||
@ -122,14 +113,27 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
request.Perform(api);
|
request.Perform(api);
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
// 404s (and maybe other failures) don't fire request.Failure so for now they handled here as well
|
||||||
|
handleRequestFailure(request, notification, e);
|
||||||
}
|
}
|
||||||
}, TaskCreationOptions.LongRunning);
|
}, TaskCreationOptions.LongRunning);
|
||||||
|
|
||||||
DownloadBegan?.Invoke(request);
|
DownloadBegan?.Invoke(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleRequestFailure(ArchiveDownloadRequest<TModel> req, ProgressNotification notification, Exception e)
|
||||||
|
{
|
||||||
|
DownloadFailed?.Invoke(req);
|
||||||
|
|
||||||
|
if (e is OperationCanceledException) return;
|
||||||
|
|
||||||
|
notification.State = ProgressNotificationState.Cancelled;
|
||||||
|
Logger.Error(e, $"{HumanisedModelName.Titleize()} download failed!");
|
||||||
|
currentDownloads.Remove(req);
|
||||||
|
}
|
||||||
|
|
||||||
private class DownloadNotification : ProgressNotification
|
private class DownloadNotification : ProgressNotification
|
||||||
{
|
{
|
||||||
public override bool IsImportant => false;
|
public override bool IsImportant => false;
|
||||||
|
@ -8,15 +8,13 @@ namespace osu.Game.Online.API.Requests
|
|||||||
public class DownloadBeatmapSetRequest : ArchiveDownloadRequest<BeatmapSetInfo>
|
public class DownloadBeatmapSetRequest : ArchiveDownloadRequest<BeatmapSetInfo>
|
||||||
{
|
{
|
||||||
private readonly bool noVideo;
|
private readonly bool noVideo;
|
||||||
private readonly BeatmapSetInfo set;
|
|
||||||
|
|
||||||
public DownloadBeatmapSetRequest(BeatmapSetInfo set, bool noVideo)
|
public DownloadBeatmapSetRequest(BeatmapSetInfo set, bool noVideo)
|
||||||
: base(set)
|
: base(set)
|
||||||
{
|
{
|
||||||
this.noVideo = noVideo;
|
this.noVideo = noVideo;
|
||||||
this.set = set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string Target => $@"beatmapsets/{set.OnlineBeatmapSetID}/download{(noVideo ? "?noVideo=1" : "")}";
|
protected override string Target => $@"beatmapsets/{Model.OnlineBeatmapSetID}/download{(noVideo ? "?noVideo=1" : "")}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user