diff --git a/osu.Game/Beatmaps/BeatmapImporter.cs b/osu.Game/Beatmaps/BeatmapImporter.cs
index 4752a88199..4731a70753 100644
--- a/osu.Game/Beatmaps/BeatmapImporter.cs
+++ b/osu.Game/Beatmaps/BeatmapImporter.cs
@@ -35,7 +35,7 @@ namespace osu.Game.Beatmaps
protected override string[] HashableFileTypes => new[] { ".osu" };
- public Action<(BeatmapSetInfo beatmapSet, bool isBatch)>? ProcessBeatmap { private get; set; }
+ public ProcessBeatmapDelegate? ProcessBeatmap { private get; set; }
public BeatmapImporter(Storage storage, RealmAccess realm)
: base(storage, realm)
@@ -59,7 +59,7 @@ namespace osu.Game.Beatmaps
first.PerformRead(s =>
{
// Re-run processing even in this case. We might have outdated metadata.
- ProcessBeatmap?.Invoke((s, false));
+ ProcessBeatmap?.Invoke(s, MetadataLookupScope.OnlineFirst);
});
return first;
}
@@ -206,7 +206,7 @@ namespace osu.Game.Beatmaps
protected override void PostImport(BeatmapSetInfo model, Realm realm, ImportParameters parameters)
{
base.PostImport(model, realm, parameters);
- ProcessBeatmap?.Invoke((model, parameters.Batch));
+ ProcessBeatmap?.Invoke(model, parameters.Batch ? MetadataLookupScope.LocalCacheFirst : MetadataLookupScope.OnlineFirst);
}
private void validateOnlineIds(BeatmapSetInfo beatmapSet, Realm realm)
diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs
index ad56bbbc3a..cab49b7d69 100644
--- a/osu.Game/Beatmaps/BeatmapManager.cs
+++ b/osu.Game/Beatmaps/BeatmapManager.cs
@@ -42,7 +42,7 @@ namespace osu.Game.Beatmaps
private readonly WorkingBeatmapCache workingBeatmapCache;
- public Action<(BeatmapSetInfo beatmapSet, bool isBatch)>? ProcessBeatmap { private get; set; }
+ public ProcessBeatmapDelegate? ProcessBeatmap { private get; set; }
public override bool PauseImports
{
@@ -72,7 +72,7 @@ namespace osu.Game.Beatmaps
BeatmapTrackStore = audioManager.GetTrackStore(userResources);
beatmapImporter = CreateBeatmapImporter(storage, realm);
- beatmapImporter.ProcessBeatmap = args => ProcessBeatmap?.Invoke(args);
+ beatmapImporter.ProcessBeatmap = (beatmapSet, scope) => ProcessBeatmap?.Invoke(beatmapSet, scope);
beatmapImporter.PostNotification = obj => PostNotification?.Invoke(obj);
workingBeatmapCache = CreateWorkingBeatmapCache(audioManager, gameResources, userResources, defaultBeatmap, host);
@@ -454,7 +454,9 @@ namespace osu.Game.Beatmaps
if (transferCollections)
beatmapInfo.TransferCollectionReferences(r, oldMd5Hash);
- ProcessBeatmap?.Invoke((liveBeatmapSet, false));
+ // do not look up metadata.
+ // this is a locally-modified set now, so looking up metadata is busy work at best and harmful at worst.
+ ProcessBeatmap?.Invoke(liveBeatmapSet, MetadataLookupScope.None);
});
}
@@ -542,4 +544,11 @@ namespace osu.Game.Beatmaps
public override string HumanisedModelName => "beatmap";
}
+
+ ///
+ /// Delegate type for beatmap processing callbacks.
+ ///
+ /// The beatmap set to be processed.
+ /// The scope to use when looking up metadata.
+ public delegate void ProcessBeatmapDelegate(BeatmapSetInfo beatmapSet, MetadataLookupScope lookupScope);
}
diff --git a/osu.Game/Beatmaps/BeatmapOnlineChangeIngest.cs b/osu.Game/Beatmaps/BeatmapOnlineChangeIngest.cs
index 98aefd75d3..b160043820 100644
--- a/osu.Game/Beatmaps/BeatmapOnlineChangeIngest.cs
+++ b/osu.Game/Beatmaps/BeatmapOnlineChangeIngest.cs
@@ -36,7 +36,7 @@ namespace osu.Game.Beatmaps
var matchingSet = r.All().FirstOrDefault(s => s.OnlineID == id);
if (matchingSet != null)
- beatmapUpdater.Queue(matchingSet.ToLive(realm), true);
+ beatmapUpdater.Queue(matchingSet.ToLive(realm), MetadataLookupScope.OnlineFirst);
}
});
}
diff --git a/osu.Game/Beatmaps/BeatmapUpdater.cs b/osu.Game/Beatmaps/BeatmapUpdater.cs
index d7b1fac7b3..af9f32f834 100644
--- a/osu.Game/Beatmaps/BeatmapUpdater.cs
+++ b/osu.Game/Beatmaps/BeatmapUpdater.cs
@@ -42,24 +42,25 @@ namespace osu.Game.Beatmaps
/// Queue a beatmap for background processing.
///
/// The managed beatmap set to update. A transaction will be opened to apply changes.
- /// Whether metadata from an online source should be preferred. If true, the local cache will be skipped to ensure the freshest data state possible.
- public void Queue(Live beatmapSet, bool preferOnlineFetch = false)
+ /// The preferred scope to use for metadata lookup.
+ public void Queue(Live beatmapSet, MetadataLookupScope lookupScope = MetadataLookupScope.LocalCacheFirst)
{
Logger.Log($"Queueing change for local beatmap {beatmapSet}");
- Task.Factory.StartNew(() => beatmapSet.PerformRead(b => Process(b, preferOnlineFetch)), default, TaskCreationOptions.HideScheduler | TaskCreationOptions.RunContinuationsAsynchronously, updateScheduler);
+ Task.Factory.StartNew(() => beatmapSet.PerformRead(b => Process(b, lookupScope)), default, TaskCreationOptions.HideScheduler | TaskCreationOptions.RunContinuationsAsynchronously, updateScheduler);
}
///
/// Run all processing on a beatmap immediately.
///
/// The managed beatmap set to update. A transaction will be opened to apply changes.
- /// Whether metadata from an online source should be preferred. If true, the local cache will be skipped to ensure the freshest data state possible.
- public void Process(BeatmapSetInfo beatmapSet, bool preferOnlineFetch = false) => beatmapSet.Realm.Write(r =>
+ /// The preferred scope to use for metadata lookup.
+ public void Process(BeatmapSetInfo beatmapSet, MetadataLookupScope lookupScope = MetadataLookupScope.LocalCacheFirst) => beatmapSet.Realm.Write(r =>
{
// Before we use below, we want to invalidate.
workingBeatmapCache.Invalidate(beatmapSet);
- metadataLookup.Update(beatmapSet, preferOnlineFetch);
+ if (lookupScope != MetadataLookupScope.None)
+ metadataLookup.Update(beatmapSet, lookupScope == MetadataLookupScope.OnlineFirst);
foreach (var beatmap in beatmapSet.Beatmaps)
{
diff --git a/osu.Game/Beatmaps/MetadataLookupScope.cs b/osu.Game/Beatmaps/MetadataLookupScope.cs
new file mode 100644
index 0000000000..e1fbedc26a
--- /dev/null
+++ b/osu.Game/Beatmaps/MetadataLookupScope.cs
@@ -0,0 +1,26 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+namespace osu.Game.Beatmaps
+{
+ ///
+ /// Determines which sources (if any at all) should be queried in which order for a beatmap's metadata.
+ ///
+ public enum MetadataLookupScope
+ {
+ ///
+ /// Do not attempt to look up the beatmap metadata either in the local cache or online.
+ ///
+ None,
+
+ ///
+ /// Try the local metadata cache first before querying online sources.
+ ///
+ LocalCacheFirst,
+
+ ///
+ /// Query online sources immediately.
+ ///
+ OnlineFirst
+ }
+}
diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs
index 8f27e5dc53..34e31b0d61 100644
--- a/osu.Game/OsuGameBase.cs
+++ b/osu.Game/OsuGameBase.cs
@@ -310,7 +310,7 @@ namespace osu.Game
base.Content.Add(new BeatmapOnlineChangeIngest(beatmapUpdater, realm, metadataClient));
- BeatmapManager.ProcessBeatmap = args => beatmapUpdater.Process(args.beatmapSet, !args.isBatch);
+ BeatmapManager.ProcessBeatmap = (beatmapSet, scope) => beatmapUpdater.Process(beatmapSet, scope);
dependencies.Cache(userCache = new UserLookupCache());
base.Content.Add(userCache);