diff --git a/app/application/history/retry.py b/app/application/history/retry.py index d7720125e..dd70eb976 100644 --- a/app/application/history/retry.py +++ b/app/application/history/retry.py @@ -18,8 +18,8 @@ from app.runtime.log import logger MIN_FAILED_RETRIES = 1 MAX_FAILED_RETRIES = 10 FAILED_RETRY_TTL = 24 * 3600 -# 不同存储后端对秒级修改时间的浮点和序列化误差可能达到毫秒;更大的变化仍视为新版本。 -MODIFY_TIME_TOLERANCE = 1e-3 +# 不同存储后端的修改时间精度和序列化可能产生秒级差异;超过 1 秒才视为新版本。 +MODIFY_TIME_TOLERANCE = 1.0 # 缓存值会同时保存文件指纹,使同一路径的新版本获得独立重试预算。 _failed_retry_counts = TTLCache( diff --git a/tests/test_transfer_history_gate.py b/tests/test_transfer_history_gate.py index 7925fee84..938b8c39a 100644 --- a/tests/test_transfer_history_gate.py +++ b/tests/test_transfer_history_gate.py @@ -82,14 +82,14 @@ def test_evaluate_history_gate_skips_when_success_size_unchanged(): @pytest.mark.parametrize( "current_modify_time, expected", [ - (100.0005, HistoryGateAction.SKIP), - (100.01, HistoryGateAction.PASS_SIZE_CHANGED), + (101.0, HistoryGateAction.SKIP), + (101.01, HistoryGateAction.PASS_SIZE_CHANGED), ], ) def test_evaluate_history_gate_uses_tolerance_for_modify_time( current_modify_time, expected, ): - """修改时间仅有毫秒级浮点漂移时应保持原版本,明显变化仍应放行。""" + """修改时间变化不超过 1 秒时应保持原版本,超过 1 秒仍应放行。""" history = make_history(status=True, size=1024, modify_time=100.0) action = evaluate_history_gate(