mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Remove async when not required
This commit is contained in:
parent
c4f54d94bc
commit
fd7dc9504e
@ -94,7 +94,7 @@ namespace osu.Game.Beatmaps
|
|||||||
updateQueue = new BeatmapUpdateQueue(api);
|
updateQueue = new BeatmapUpdateQueue(api);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive, CancellationToken cancellationToken = default)
|
protected override Task Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
if (archive != null)
|
if (archive != null)
|
||||||
beatmapSet.Beatmaps = createBeatmapDifficulties(archive);
|
beatmapSet.Beatmaps = createBeatmapDifficulties(archive);
|
||||||
@ -110,7 +110,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
validateOnlineIds(beatmapSet);
|
validateOnlineIds(beatmapSet);
|
||||||
|
|
||||||
await updateQueue.UpdateAsync(beatmapSet, cancellationToken);
|
return updateQueue.UpdateAsync(beatmapSet, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PreImport(BeatmapSetInfo beatmapSet)
|
protected override void PreImport(BeatmapSetInfo beatmapSet)
|
||||||
@ -433,13 +433,13 @@ namespace osu.Game.Beatmaps
|
|||||||
this.api = api;
|
this.api = api;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateAsync(BeatmapSetInfo beatmapSet, CancellationToken cancellationToken)
|
public Task UpdateAsync(BeatmapSetInfo beatmapSet, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (api?.State != APIState.Online)
|
if (api?.State != APIState.Online)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
LogForModel(beatmapSet, "Performing online lookups...");
|
LogForModel(beatmapSet, "Performing online lookups...");
|
||||||
await Task.WhenAll(beatmapSet.Beatmaps.Select(b => UpdateAsync(beatmapSet, b, cancellationToken)).ToArray());
|
return Task.WhenAll(beatmapSet.Beatmaps.Select(b => UpdateAsync(beatmapSet, b, cancellationToken)).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: expose this when we need to do individual difficulty lookups.
|
// todo: expose this when we need to do individual difficulty lookups.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -132,13 +132,13 @@ namespace osu.Game.Database
|
|||||||
/// This will post notifications tracking progress.
|
/// This will post notifications tracking progress.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="paths">One or more archive locations on disk.</param>
|
/// <param name="paths">One or more archive locations on disk.</param>
|
||||||
public async Task Import(params string[] paths)
|
public Task Import(params string[] paths)
|
||||||
{
|
{
|
||||||
var notification = new ProgressNotification { State = ProgressNotificationState.Active };
|
var notification = new ProgressNotification { State = ProgressNotificationState.Active };
|
||||||
|
|
||||||
PostNotification?.Invoke(notification);
|
PostNotification?.Invoke(notification);
|
||||||
|
|
||||||
await Import(notification, paths);
|
return Import(notification, paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task Import(ProgressNotification notification, params string[] paths)
|
protected async Task Import(ProgressNotification notification, params string[] paths)
|
||||||
@ -243,7 +243,7 @@ namespace osu.Game.Database
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="archive">The archive to be imported.</param>
|
/// <param name="archive">The archive to be imported.</param>
|
||||||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||||
public async Task<TModel> Import(ArchiveReader archive, CancellationToken cancellationToken = default)
|
public Task<TModel> Import(ArchiveReader archive, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ namespace osu.Game.Database
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await Import(model, archive, cancellationToken);
|
return Import(model, archive, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -548,24 +548,24 @@ namespace osu.Game.Database
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is a temporary method and will likely be replaced by a full-fledged (and more correctly placed) migration process in the future.
|
/// This is a temporary method and will likely be replaced by a full-fledged (and more correctly placed) migration process in the future.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task ImportFromStableAsync()
|
public Task ImportFromStableAsync()
|
||||||
{
|
{
|
||||||
var stable = GetStableStorage?.Invoke();
|
var stable = GetStableStorage?.Invoke();
|
||||||
|
|
||||||
if (stable == null)
|
if (stable == null)
|
||||||
{
|
{
|
||||||
Logger.Log("No osu!stable installation available!", LoggingTarget.Information, LogLevel.Error);
|
Logger.Log("No osu!stable installation available!", LoggingTarget.Information, LogLevel.Error);
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stable.ExistsDirectory(ImportFromStablePath))
|
if (!stable.ExistsDirectory(ImportFromStablePath))
|
||||||
{
|
{
|
||||||
// This handles situations like when the user does not have a Skins folder
|
// This handles situations like when the user does not have a Skins folder
|
||||||
Logger.Log($"No {ImportFromStablePath} folder available in osu!stable installation", LoggingTarget.Information, LogLevel.Error);
|
Logger.Log($"No {ImportFromStablePath} folder available in osu!stable installation", LoggingTarget.Information, LogLevel.Error);
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.Run(async () => await Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray()));
|
return Task.Run(async () => await Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user