fix: 编号进度被拒绝访问时继续下载

This commit is contained in:
2026-10-25 08:53:15 +08:00
parent 69c7df85d3
commit e99a112965
4 changed files with 68 additions and 7 deletions
+23
View File
@@ -323,6 +323,29 @@ async def _server_error_is_retried(monkeypatch):
assert waits == [1, 3, 9]
def test_spool_keeps_downloading_when_meta_replace_is_denied(monkeypatch, tmp_path: Path):
sleeps: list[float] = []
monkeypatch.setattr(spool_module.time, "sleep", lambda seconds: sleeps.append(seconds))
spool = IdSpool(tmp_path)
spool.open()
real = spool_module.os.replace
calls = {"n": 0}
def flaky(src, dst):
calls["n"] += 1
if calls["n"] == 1:
raise PermissionError(13, "Access is denied", str(src), 5)
real(src, dst)
monkeypatch.setattr(spool_module.os, "replace", flaky)
assert spool.add("10") is True
spool.flush()
assert spool.committed == 1
assert IdSpool._peek(tmp_path)["committed"] == 1
assert calls["n"] == 2
assert sleeps
def test_spool_dedups_ints_and_drops_uncommitted_tail(monkeypatch, tmp_path: Path):
clock = {"now": 10.0}
monkeypatch.setattr(spool_module.time, "monotonic", lambda: clock["now"])