feat: 进度改为目录轮询驱动, 每秒刷新 (绕过后端输出缓冲, stdbuf在Android无效)
This commit is contained in:
1 parent
e4da65b951
commit
a9fe6ff068
2 files changed
+74
-25
No files matched your search
@@ -270,3 +270,15 @@ def test_speed_stats_empty():
|
||||
def test_speed_stats_single():
|
||||
cur, peak, avg = transfer.speed_stats([8 * 1024 * 1024])
|
||||
assert (cur, peak, avg) == (8 * 1024 * 1024, 8 * 1024 * 1024, 8 * 1024 * 1024)
|
||||
|
||||
# ---------- 目录大小轮询 (rsync 输出缓冲替代方案) ----------
|
||||
|
||||
def test_dir_size_returns_bytes(tmp_path):
|
||||
"""du 目录返回字节数"""
|
||||
(tmp_path / "a.bin").write_bytes(b"x" * 1000)
|
||||
(tmp_path / "sub").mkdir()
|
||||
(tmp_path / "sub" / "b.bin").write_bytes(b"y" * 500)
|
||||
assert transfer.dir_size(str(tmp_path)) == 1500
|
||||
|
||||
def test_dir_size_missing_returns_zero():
|
||||
assert transfer.dir_size("/nonexistent/path/xyz") == 0
|
||||
Reference in new issue
Block a user