Skip to content

Commit

Permalink
Add note about expensive operation
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Dec 10, 2024
1 parent 84b00e1 commit c68d4af
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions osu.Game/Screens/Edit/Setup/ResourcesSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,17 @@ private void changeResource(FileInfo source, bool applyToAllDifficulties, string
{
foreach (var b in otherBeatmaps)
{
if (readFilename(b.Metadata) != newFilename)
{
writeFilename(b.Metadata, newFilename);

// save the difficulty to re-encode the .osu file, updating any reference of the old filename.
var beatmapWorking = beatmaps.GetWorkingBeatmap(b);
beatmaps.Save(b, beatmapWorking.Beatmap, beatmapWorking.GetSkin());
}
// This operation is quite expensive, so only perform it if required.
if (readFilename(b.Metadata) == newFilename) continue;

writeFilename(b.Metadata, newFilename);

// save the difficulty to re-encode the .osu file, updating any reference of the old filename.
//
// note that this triggers a full save flow, including triggering a difficulty calculation.
// this is not a cheap operation and should be reconsidered in the future.
var beatmapWorking = beatmaps.GetWorkingBeatmap(b);
beatmaps.Save(b, beatmapWorking.Beatmap, beatmapWorking.GetSkin());
}
}

Expand Down

0 comments on commit c68d4af

Please sign in to comment.