后台保存定价的版本推进改为饱和加法
- server-rs/crates/api-server/src/state.rs:expected_updated_at_micros 来自后台请求体、只校验了必须给出,没有范围校验;expected + 1 在 i64::MAX 上会溢出(debug 下 panic、release 下回绕成 i64::MIN 并让版本推进失效),改用 saturating_add(与测试分支同一口径)
This commit is contained in:
@@ -868,8 +868,10 @@ impl AppState {
|
||||
let records = editor_generation_pricing_to_records(&next)?;
|
||||
// 版本取「当前时间」与「期望版本 + 1」的较大值:同一微秒内的连续保存也必须推进版本,
|
||||
// 否则旧的期望版本会在下一次保存时被误判为仍然有效。
|
||||
let updated_at_micros =
|
||||
crate::editor_project::current_utc_micros().max(expected_updated_at_micros + 1);
|
||||
// expected_updated_at_micros 来自后台请求体,只有「必须给出」的校验、没有范围校验:
|
||||
// 直接 +1 在 i64::MAX 上会溢出(debug 下 panic,release 下回绕成 i64::MIN)。
|
||||
let updated_at_micros = crate::editor_project::current_utc_micros()
|
||||
.max(expected_updated_at_micros.saturating_add(1));
|
||||
let record = self
|
||||
.spacetime_client
|
||||
.upsert_editor_generation_pricing_config(editor_generation_pricing_upsert_input(
|
||||
|
||||
Reference in New Issue
Block a user