mirror of https://github.com/ppy/osu
Change DownloadState only when Download is possible
This commit is contained in:
parent
c4a1c466bc
commit
86b29064c6
|
@ -148,11 +148,12 @@ protected override BeatmapSetInfo CheckForExisting(BeatmapSetInfo model)
|
|||
/// </summary>
|
||||
/// <param name="beatmapSetInfo">The <see cref="BeatmapSetInfo"/> to be downloaded.</param>
|
||||
/// <param name="noVideo">Whether the beatmap should be downloaded without video. Defaults to false.</param>
|
||||
public void Download(BeatmapSetInfo beatmapSetInfo, bool noVideo = false)
|
||||
/// <returns>Downloading can happen</returns>
|
||||
public bool Download(BeatmapSetInfo beatmapSetInfo, bool noVideo = false)
|
||||
{
|
||||
var existing = GetExistingDownload(beatmapSetInfo);
|
||||
|
||||
if (existing != null || api == null) return;
|
||||
if (existing != null || api == null) return false;
|
||||
|
||||
if (!api.LocalUser.Value.IsSupporter)
|
||||
{
|
||||
|
@ -161,7 +162,7 @@ public void Download(BeatmapSetInfo beatmapSetInfo, bool noVideo = false)
|
|||
Icon = FontAwesome.fa_superpowers,
|
||||
Text = "You gotta be an osu!supporter to download for now 'yo"
|
||||
});
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
var downloadNotification = new DownloadNotification
|
||||
|
@ -227,6 +228,7 @@ public void Download(BeatmapSetInfo beatmapSetInfo, bool noVideo = false)
|
|||
// don't run in the main api queue as this is a long-running task.
|
||||
Task.Factory.StartNew(() => request.Perform(api), TaskCreationOptions.LongRunning);
|
||||
BeatmapDownloadBegan?.Invoke(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void PresentCompletedImport(IEnumerable<BeatmapSetInfo> imported)
|
||||
|
|
|
@ -71,9 +71,10 @@ public void Download()
|
|||
if (DownloadState.Value > DownloadStatus.NotDownloaded)
|
||||
return;
|
||||
|
||||
beatmaps.Download(set, noVideo);
|
||||
|
||||
DownloadState.Value = DownloadStatus.Downloading;
|
||||
if (beatmaps.Download(set, noVideo)) {
|
||||
// Only change state if download can happen
|
||||
DownloadState.Value = DownloadStatus.Downloading;
|
||||
}
|
||||
}
|
||||
|
||||
private void setAdded(BeatmapSetInfo s)
|
||||
|
|
Loading…
Reference in New Issue