mirror of
https://github.com/ppy/osu.git
synced 2025-01-09 04:23:22 +08:00
Merge pull request #8494 from peppy/fix-invalid-set-ids-on-import
Fix imports with no matching beatmap IDs still retaining a potentially invalid set ID
This commit is contained in:
commit
e0a876ceaf
@ -87,7 +87,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
protected override bool ShouldDeleteArchive(string path) => Path.GetExtension(path)?.ToLowerInvariant() == ".osz";
|
protected override bool ShouldDeleteArchive(string path) => Path.GetExtension(path)?.ToLowerInvariant() == ".osz";
|
||||||
|
|
||||||
protected override Task Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive, CancellationToken cancellationToken = default)
|
protected override async Task Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
if (archive != null)
|
if (archive != null)
|
||||||
beatmapSet.Beatmaps = createBeatmapDifficulties(beatmapSet.Files);
|
beatmapSet.Beatmaps = createBeatmapDifficulties(beatmapSet.Files);
|
||||||
@ -103,7 +103,19 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
validateOnlineIds(beatmapSet);
|
validateOnlineIds(beatmapSet);
|
||||||
|
|
||||||
return updateQueue.UpdateAsync(beatmapSet, cancellationToken);
|
bool hadOnlineBeatmapIDs = beatmapSet.Beatmaps.Any(b => b.OnlineBeatmapID > 0);
|
||||||
|
|
||||||
|
await updateQueue.UpdateAsync(beatmapSet, cancellationToken);
|
||||||
|
|
||||||
|
// ensure at least one beatmap was able to retrieve or keep an online ID, else drop the set ID.
|
||||||
|
if (hadOnlineBeatmapIDs && !beatmapSet.Beatmaps.Any(b => b.OnlineBeatmapID > 0))
|
||||||
|
{
|
||||||
|
if (beatmapSet.OnlineBeatmapSetID != null)
|
||||||
|
{
|
||||||
|
beatmapSet.OnlineBeatmapSetID = null;
|
||||||
|
LogForModel(beatmapSet, "Disassociating beatmap set ID due to loss of all beatmap IDs");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PreImport(BeatmapSetInfo beatmapSet)
|
protected override void PreImport(BeatmapSetInfo beatmapSet)
|
||||||
@ -447,6 +459,8 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
var res = req.Result;
|
var res = req.Result;
|
||||||
|
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
beatmap.Status = res.Status;
|
beatmap.Status = res.Status;
|
||||||
beatmap.BeatmapSet.Status = res.BeatmapSet.Status;
|
beatmap.BeatmapSet.Status = res.BeatmapSet.Status;
|
||||||
beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID;
|
beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID;
|
||||||
@ -454,6 +468,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
LogForModel(set, $"Online retrieval mapped {beatmap} to {res.OnlineBeatmapSetID} / {res.OnlineBeatmapID}.");
|
LogForModel(set, $"Online retrieval mapped {beatmap} to {res.OnlineBeatmapSetID} / {res.OnlineBeatmapID}.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
fail(e);
|
fail(e);
|
||||||
|
@ -12,11 +12,11 @@ namespace osu.Game.Online.API
|
|||||||
/// An API request with a well-defined response type.
|
/// An API request with a well-defined response type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">Type of the response (used for deserialisation).</typeparam>
|
/// <typeparam name="T">Type of the response (used for deserialisation).</typeparam>
|
||||||
public abstract class APIRequest<T> : APIRequest
|
public abstract class APIRequest<T> : APIRequest where T : class
|
||||||
{
|
{
|
||||||
protected override WebRequest CreateWebRequest() => new OsuJsonWebRequest<T>(Uri);
|
protected override WebRequest CreateWebRequest() => new OsuJsonWebRequest<T>(Uri);
|
||||||
|
|
||||||
public T Result => ((OsuJsonWebRequest<T>)WebRequest).ResponseObject;
|
public T Result => ((OsuJsonWebRequest<T>)WebRequest)?.ResponseObject;
|
||||||
|
|
||||||
protected APIRequest()
|
protected APIRequest()
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@ using osu.Game.Rulesets;
|
|||||||
|
|
||||||
namespace osu.Game.Online.API.Requests
|
namespace osu.Game.Online.API.Requests
|
||||||
{
|
{
|
||||||
public abstract class GetRankingsRequest<TModel> : APIRequest<TModel>
|
public abstract class GetRankingsRequest<TModel> : APIRequest<TModel> where TModel : class
|
||||||
{
|
{
|
||||||
private readonly RulesetInfo ruleset;
|
private readonly RulesetInfo ruleset;
|
||||||
private readonly int page;
|
private readonly int page;
|
||||||
|
@ -6,7 +6,7 @@ using osu.Framework.IO.Network;
|
|||||||
|
|
||||||
namespace osu.Game.Online.API.Requests
|
namespace osu.Game.Online.API.Requests
|
||||||
{
|
{
|
||||||
public abstract class PaginatedAPIRequest<T> : APIRequest<T>
|
public abstract class PaginatedAPIRequest<T> : APIRequest<T> where T : class
|
||||||
{
|
{
|
||||||
private readonly int page;
|
private readonly int page;
|
||||||
private readonly int itemsPerPage;
|
private readonly int itemsPerPage;
|
||||||
|
Loading…
Reference in New Issue
Block a user