fix(transfer): tolerate one-second mtime drift

This commit is contained in:
jxxghp
2026-09-28 07:52:15 +08:00
parent 1374328f84
commit d4dd646d50
2 changed files with 5 additions and 5 deletions

View File

@@ -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(

View File

@@ -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(