@@ -51,3 +51,33 @@ def test_watch_scope_does_not_scan_sibling_media(tmp_path):
5151 assert str ((src / "main.py" ).resolve ()) in hashed_paths
5252 assert str (readme .resolve ()) in hashed_paths
5353 assert str ((assets / "icon.png" ).resolve ()) not in hashed_paths
54+
55+
56+ def test_mixed_txt_and_bin_directory_skips_bin_without_crash (tmp_path ):
57+ """Same dir with .txt and .bin: hash only text, ignore binary (review #377)."""
58+ docs = tmp_path / "docs"
59+ docs .mkdir ()
60+ txt = docs / "notes.txt"
61+ bin_file = docs / "payload.bin"
62+ txt .write_text ("hello" , encoding = "utf-8" )
63+ bin_file .write_bytes (bytes (range (256 )))
64+
65+ fs = FileSynchronizer (
66+ root_dir = str (docs ),
67+ include_extensions = [".txt" ],
68+ snapshot_path = str (tmp_path / "sync.pickle" ),
69+ auto_load = False ,
70+ )
71+
72+ hashes = fs .generate_file_hashes ()
73+ assert set (hashes .keys ()) == {str (txt .resolve ())}
74+ assert str (bin_file .resolve ()) not in hashes
75+
76+ fs .create_snapshot ()
77+ fs2 = FileSynchronizer (
78+ root_dir = str (docs ),
79+ include_extensions = [".txt" ],
80+ snapshot_path = str (tmp_path / "sync.pickle" ),
81+ )
82+ added , removed , modified = fs2 .detect_changes ()
83+ assert not added and not removed and not modified
0 commit comments