@@ -228,17 +228,30 @@ def test_backup_default_labels_only(tmp_path):
228228 assert backup_if_protected (tmp_path ) is None
229229
230230
231- def test_backup_same_day_collision (tmp_path ):
232- """Second backup on same day gets _2 suffix ."""
231+ def test_backup_same_day_no_accumulation (tmp_path ):
232+ """Same content on same day returns existing backup dir without re-copying ."""
233233 from graphify .export import backup_if_protected
234234 from datetime import date
235235 (tmp_path / "graph.json" ).write_text ('{"nodes":[],"links":[]}' )
236236 (tmp_path / ".graphify_semantic_marker" ).write_text ("{}" )
237237 b1 = backup_if_protected (tmp_path )
238238 b2 = backup_if_protected (tmp_path )
239239 assert b1 is not None and b2 is not None
240- assert b1 != b2
241- assert b2 .name == f"{ date .today ().isoformat ()} _2"
240+ assert b1 == b2 # same dir, no _2 accumulation
241+ assert b1 .name == date .today ().isoformat ()
242+
243+
244+ def test_backup_same_day_changed_content (tmp_path ):
245+ """Changed graph.json on same day overwrites the existing backup in place."""
246+ from graphify .export import backup_if_protected
247+ from datetime import date
248+ (tmp_path / "graph.json" ).write_text ('{"nodes":[],"links":[]}' )
249+ (tmp_path / ".graphify_semantic_marker" ).write_text ("{}" )
250+ b1 = backup_if_protected (tmp_path )
251+ (tmp_path / "graph.json" ).write_text ('{"nodes":[{"id":"x"}],"links":[]}' )
252+ b2 = backup_if_protected (tmp_path )
253+ assert b1 == b2 # still one folder per day
254+ assert (b2 / "graph.json" ).read_text () == '{"nodes":[{"id":"x"}],"links":[]}'
242255
243256
244257def test_backup_env_disable (tmp_path , monkeypatch ):
0 commit comments