refactor(temp): read the free space where the failed step deletes its temp files

This commit is contained in:
imSp4rky
2026-11-29 15:23:03 -07:00
parent 977cbe4aa8
commit 1ebc3e3624
13 changed files with 155 additions and 59 deletions
+17
View File
@@ -13,6 +13,7 @@ from uuid import UUID
import pytest
from tests.core.test_all_drm import playready, widevine
from unshackle.core import temp
from unshackle.core.constants import DOWNLOAD_CANCELLED
from unshackle.core.drm import ClearKey, ClearKeyCENC, ClearKeyCTR, MonaLisa, verify
from unshackle.core.events import events
@@ -192,6 +193,22 @@ def test_a_failure_closes_the_decrypter_and_removes_the_output(tmp_path, seen):
assert not ctx.save_path.exists()
def test_a_failed_rolling_merge_reads_the_free_space_before_it_removes_the_output(tmp_path, monkeypatch):
ctx = make_ctx(tmp_path)
present: list[bool] = []
def usage(path: Any) -> Any:
present.append(ctx.save_path.exists())
return SimpleNamespace(free=38_000_000)
monkeypatch.setattr(temp.shutil, "disk_usage", usage)
with pytest.raises(ConnectionError) as raised:
fetch(ctx, FakeDownloader(fail_after=2), rolling=True, init=INIT)
assert present == [True] and not ctx.save_path.exists()
assert temp.low_free_space(raised.value).startswith(", 38.0 MB free on ")
def test_a_short_rolling_merge_raises_and_removes_the_output(tmp_path):
ctx = make_ctx(tmp_path)
ctx.save_path.write_bytes(INIT)