Skip to content

Clear an earlier LAVA export's media before re-exporting into its folder - #247

Merged
charpy4n6 merged 1 commit into
mainfrom
fix/lava-reexport-stale-media
Oct 1, 2026
Merged

charpy4n6 merged 1 commit into
mainfrom
fix/lava-reexport-stale-media

Conversation

@charpy4n6

Copy link
Copy Markdown
Collaborator

Fixes #243

Each export rebuilds the LAVA database, but media/ and _HTML/media/ were kept, and a file already there was not copied again. So a narrower re-export into the same folder still held every file the wider one had, and the run log's "Media files written" counted only that run's new copies.

  • _Writer now empties media/ and _HTML/media/ before writing when the folder already holds a LAVA database or manifest. The folder then holds exactly what the new report lists. Deleting a hardlinked copy removes only that name, never the evidence file.
  • A folder whose media folder sits beside no LAVA database or manifest is refused (FileExistsError), not deleted.
  • The run log lines now read "Media files in the report" and "Media bytes in the report". With the folder cleared first, those counts equal the files in _lava_media_items.

Tests in tests/test_lava.py:

  • test_a_narrower_re_export_leaves_no_earlier_media_behind exports all, then the same scope again, then one file, into one folder. After each export, the database, media/, _HTML/media/ and the run log count must agree.
  • test_media_folders_that_are_not_a_lava_export_are_left_alone checks that a foreign media folder is refused and left untouched.

Both fail on main. All 40 tests in test_lava.py pass, and lint_changed.py reports no new warnings.

🤖 Generated with Claude Code

The database is rebuilt on every export but media/ and _HTML/media/ were
kept, and a file already there was not copied again. A narrower re-export
into the same folder therefore handed over every file the wider one held,
and "Media files written" counted only this run's copies.

An export into a folder that holds a LAVA database or manifest now empties
its two media folders first, so the folder holds exactly what the report
lists and the run log's count is the report's. A media folder beside no
LAVA export is refused rather than deleted. The run log lines now read
"Media files in the report" and "Media bytes in the report".

Fixes #243

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@charpy4n6
charpy4n6 merged commit bd53679 into main Oct 1, 2026
8 checks passed
@charpy4n6
charpy4n6 deleted the fix/lava-reexport-stale-media branch October 1, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LAVA re-export into the same folder keeps earlier media and undercounts what the report holds

1 participant