fix(attachment): keep custom fonts after mux cleanup

Attachment.delete() now removes a file only when it is in the temp directory, so fonts attached from the custom fonts directory survive.
This commit is contained in:
imSp4rky
2026-10-04 12:18:02 -06:00
parent 825678a1c4
commit 07e6a75165
4 changed files with 27 additions and 23 deletions
+18
View File
@@ -114,3 +114,21 @@ def test_direct_session_copies_rnet_cookies_set_by_name() -> None:
new = track_module.direct_session(rs, "http://dl-proxy:2")
assert new.cookies.get("via_set") == "1"
assert new.cookies.get("via_item") == "3"
def test_delete_removes_only_files_in_the_temp_directory(tmp_path, monkeypatch) -> None:
temp = tmp_path / "temp"
temp.mkdir()
monkeypatch.setattr(config.directories, "temp", temp)
temp_font = temp / "font.ttf"
user_font = tmp_path / "font.ttf"
temp_font.write_bytes(b"font")
user_font.write_bytes(b"font")
for path in (temp_font, user_font):
attachment = Attachment(path=path)
attachment.delete()
assert attachment.path is None
assert not temp_font.exists()
assert user_font.exists()