Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.
Python adbadblockandroid-tvandroid-tv-launcherapple-tvbloatware-removalclaude-codedebloatfire-tvgoogle-tvlauncherprivacysmart-tvsony-braviatclvibe-codingxiaomi
tools: b64push.py refuses a staging path that leaves under 256 bytes per chunk (#2614)
AldySanb0421361c07f
diff --git a/tests/test_b64push_atomic.py b/tests/test_b64push_atomic.pyindex ce53580cd..0c02c25ce 100644--- a/tests/test_b64push_atomic.py+++ b/tests/test_b64push_atomic.py@@ -132,6 +132,21 @@ class B64PushTest(TempDirTest):self.assertEqual(target.read_bytes(), data)self.assertLessEqual(max(len(c) for c in self.commands()), 4096)+ def test_a_transport_too_small_for_the_staging_path_is_refused_without_sending(self):+ # The floor on the chunk from #2614: a staging name that leaves under 256 bytes per chunk,+ # or none at all, is an argument error (exit 2, nothing sent), not a push spread over one-+ # and two-byte commands, and not an empty transfer that ends in a MISMATCH either.+ target = self.remote_dir / "file.jpg"+ for fake_max in ("300", "100"):+ with self.subTest(fake_max=fake_max):+ self.log.unlink(missing_ok=True)+ result = self.push(str(self.local(b"x" * 4096)), str(target), FAKE_MAX=fake_max)+ self.assertEqual(result.returncode, 2, result.stdout + result.stderr)+ self.assertIn(f"refusing remote path '{target}'", result.stderr)+ self.assertIn("Nothing was sent to the TV.", result.stderr)+ self.assertEqual(self.commands(), [], "not even the staging cleanup ran")+ self.assertFalse(target.exists())+def test_failed_checksum_leaves_the_original_intact(self):target = self.remote_dir / "file.apk"target.write_bytes(b"old contents")diff --git a/tools/b64push.py b/tools/b64push.pyindex f7870ddd9..38f8f36ba 100644--- a/tools/b64push.py+++ b/tools/b64push.py@@ -93,10 +93,23 @@ def main():return 2b64 = remote + ".b64.part"part = remote + ".part"+ # Sized before the try on purpose: a path this transport cannot carry is an argument error, and+ # a refusal raised inside would run the finally's staging cleanup, so the push would have+ # touched the TV after all.+ # base64 of the chunk plus the echo (which names the staging file) must fit one payload+ chunk = min(CHUNK, (dev.max_chunk_size - 85 - len(b64)) * 3 // 4)+ chunk -= chunk % 3 # a multiple of 3, or each chunk ends in '=' padding mid-stream and base64 -d corrupts it+ if chunk < 256:+ # Under 256 raw bytes per chunk the transfer degenerates into one- and two-byte commands,+ # and with no room at all it sends no chunk, reports a MISMATCH and leaves the staging+ # cleanup as the only thing that ran. The path is wrong for this transport, not the+ # transfer: refused like the argument errors above, before anything is sent.+ sys.stderr.write(f"refusing remote path {remote!r}: staged as {q(b64)} it leaves under 256 "+ f"bytes per chunk at this transport's {dev.max_chunk_size}-byte limit. "+ "Nothing was sent to the TV.\n")+ dev.close()+ return 2try:- # base64 of the chunk plus the echo (which names the staging file) must fit one payload- chunk = min(CHUNK, (dev.max_chunk_size - 85 - len(b64)) * 3 // 4)- chunk -= chunk % 3 # a multiple of 3, or each chunk ends in '=' padding mid-stream and base64 -d corrupts it# Only our own temporary names are cleared; the target stays until the copy is verified.# `: >` creates the base64 file even for an empty upload, so `base64 -d` has an input.dev.shell(f"rm -f {q(b64)} {q(part)} && : > {q(b64)}")