From 7bf7d6b10e3e6dc45698576efd9845bdbf2768dd Mon Sep 17 00:00:00 2001 From: Suzumiya Date: Sat, 3 Oct 2026 16:55:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=BB=9F=E4=B8=80=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=9B=9E=E9=80=80=E4=B8=8E=E9=87=8D=E5=A4=8D=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 以 projectVersion 作为唯一用户版本标签,允许同版本重复提交和版本回退。 按 versionId 保持提交实例不可变,取消同版本旧 pending 提交并按最近提交排序。 --- .../spacetime-module/src/game_distribution.rs | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/server-rs/crates/spacetime-module/src/game_distribution.rs b/server-rs/crates/spacetime-module/src/game_distribution.rs index a243c841e..42487c025 100644 --- a/server-rs/crates/spacetime-module/src/game_distribution.rs +++ b/server-rs/crates/spacetime-module/src/game_distribution.rs @@ -1990,6 +1990,24 @@ fn create_game_distribution_version_tx( let version_number = resolve_game_distribution_version_number(max_existing_version, input.version_number)?; let now = Timestamp::from_micros_since_unix_epoch(input.now_micros); + for mut pending in ctx + .db + .game_distribution_version() + .by_game_distribution_version_game_id() + .filter(&game_id) + .filter(|version| { + version.version_number == version_number + && version.status == GAME_DISTRIBUTION_VERSION_PENDING_REVIEW + }) + { + pending.status = GAME_DISTRIBUTION_VERSION_CANCELLED.to_string(); + pending.review_reason = Some("被同一项目版本的新提交替代".to_string()); + pending.updated_at = now; + ctx.db + .game_distribution_version() + .version_id() + .update(pending); + } ctx.db .game_distribution_version() .insert(GameDistributionVersion { @@ -2855,8 +2873,8 @@ fn restore_game_distribution_game_tx( .collect::>(); candidates.sort_by(|left, right| { right - .version_number - .cmp(&left.version_number) + .updated_at + .cmp(&left.updated_at) .then_with(|| right.version_id.cmp(&left.version_id)) }); let mut version = candidates @@ -3189,8 +3207,8 @@ fn admin_game_distribution_game_snapshot( let version_count = versions.len() as u64; versions.sort_by(|left, right| { right - .version_number - .cmp(&left.version_number) + .updated_at + .cmp(&left.updated_at) .then_with(|| right.version_id.cmp(&left.version_id)) }); versions.truncate(GAME_DISTRIBUTION_ADMIN_VERSION_HISTORY_LIMIT); @@ -3347,8 +3365,8 @@ fn list_owner_game_distribution_games_tx( .collect::>(); versions.sort_by(|left, right| { right - .version_number - .cmp(&left.version_number) + .updated_at + .cmp(&left.updated_at) .then_with(|| right.version_id.cmp(&left.version_id)) }); versions.truncate(GAME_DISTRIBUTION_MAX_OWNER_VERSIONS_PER_GAME);