Skip to content

Commit 01c2b98

Browse files
committed
Ensure creator username is updated on set updates
Important in cases such as name changes. This existed in old BSS (https://github.com/peppy/osu-web-10/blob/2723bd9f63e243c506336494509d1b72fb92872d/www/web/osu-osz2-bmsubmit-upload.php#L222-L224), not sure why I didn't port that across.
1 parent 7c487cb commit 01c2b98

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

osu.Server.BeatmapSubmission/BeatmapSubmissionController.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,8 @@ private static async Task reviveBeatmapSet(MySqlConnection connection, uint user
404404
private async Task<bool> updateBeatmapSetFromArchiveAsync(osu_beatmapset beatmapSet, Stream beatmapStream, MySqlConnection db)
405405
{
406406
using var archiveReader = new ZipArchiveReader(beatmapStream);
407-
var parser = new BeatmapPackageParser(await db.GetUsernameAsync(beatmapSet.user_id));
407+
string username = await db.GetUsernameAsync(beatmapSet.user_id);
408+
var parser = new BeatmapPackageParser(username);
408409
var parseResult = parser.Parse(beatmapSet.beatmapset_id, archiveReader);
409410

410411
checkPackageSize(beatmapStream.Length, parseResult);
@@ -421,6 +422,7 @@ private async Task<bool> updateBeatmapSetFromArchiveAsync(osu_beatmapset beatmap
421422

422423
if (fileSet.SetEquals(parseResult.Files))
423424
{
425+
beatmapSet.creator = username;
424426
await db.MarkBeatmapSetUpdatedAsync(beatmapSet, transaction);
425427
await transaction.CommitAsync();
426428
return false;
@@ -454,6 +456,7 @@ private async Task<bool> updateBeatmapSetFromArchiveAsync(osu_beatmapset beatmap
454456
if (beatmapIds.Count > 0)
455457
throw new InvariantException($"Beatmap package is missing .osu files for beatmaps with IDs: {string.Join(", ", beatmapIds)}", LogLevel.Warning);
456458

459+
parseResult.BeatmapSet.creator = username;
457460
await db.UpdateBeatmapSetAsync(parseResult.BeatmapSet, transaction);
458461

459462
await transaction.CommitAsync();

osu.Server.BeatmapSubmission/DatabaseOperationExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public static Task UpdateBeatmapSetAsync(this MySqlConnection db, osu_beatmapset
286286
UPDATE `osu_beatmapsets`
287287
SET
288288
`artist` = @artist, `artist_unicode` = @artist_unicode, `title` = @title, `title_unicode` = @title_unicode,
289-
`source` = @source, `tags` = @tags, `video` = @video, `storyboard` = @storyboard,
289+
`creator` = @creator, `source` = @source, `tags` = @tags, `video` = @video, `storyboard` = @storyboard,
290290
`storyboard_hash` = @storyboard_hash, `bpm` = @bpm, `filename` = @filename, `displaytitle` = @displaytitle,
291291
`body_hash` = NULL, `header_hash` = NULL, `osz2_hash` = NULL, `active` = 1, `last_update` = CURRENT_TIMESTAMP
292292
WHERE `beatmapset_id` = @beatmapset_id
@@ -296,14 +296,15 @@ public static Task UpdateBeatmapSetAsync(this MySqlConnection db, osu_beatmapset
296296
}
297297

298298
/// <summary>
299-
/// Only bumps the <paramref name="beatmapset"/>'s <c>last_update</c> date without performing any other changes.
299+
/// Only updates the <paramref name="beatmapset"/>'s <c>last_update</c> date and <c>creator</c> name without performing any other changes.
300300
/// Used in scenarios where a submission occurred for a beatmap with no changes.
301301
/// Bumping the update date is important in such cases, because if it is e.g. an update after reviving the beatmap,
302302
/// not bumping the update date will cause the beatmap to move to the graveyard again on the next day after the update.
303+
/// Updating the creator name is important in cases of name changes, especially ones with username history scrubbed.
303304
/// </summary>
304305
public static Task MarkBeatmapSetUpdatedAsync(this MySqlConnection db, osu_beatmapset beatmapset, MySqlTransaction? transaction = null)
305306
{
306-
return db.ExecuteAsync("UPDATE `osu_beatmapsets` SET `last_update` = CURRENT_TIMESTAMP WHERE `beatmapset_id` = @beatmapset_id", beatmapset, transaction);
307+
return db.ExecuteAsync("UPDATE `osu_beatmapsets` SET `last_update` = CURRENT_TIMESTAMP, `creator` = @creator WHERE `beatmapset_id` = @beatmapset_id", beatmapset, transaction);
307308
}
308309

309310
public static async Task<ulong> InsertBeatmapsetFileAsync(this MySqlConnection db, beatmapset_file file, MySqlTransaction? transaction = null)

0 commit comments

Comments
 (0)