diff --git a/README.md b/README.md index b48c22a..28e74da 100644 --- a/README.md +++ b/README.md @@ -84,8 +84,8 @@ uv run repub cleanup-media --feeds-dir out/feeds --days 25 --dry-run ``` - Remove `--dry-run` to delete matching files. The command protects media - referenced by the latest published feed and uses a lock to avoid racing with - active crawls. + referenced by the latest published feed, lists each matched file before the + aggregate summary, and uses a lock to avoid racing with active crawls. - For config-driven deployments, pass the runtime config so cleanup uses the configured `out_dir` and media directory names: diff --git a/demo/README.md b/demo/README.md index 652959e..72c2be9 100644 --- a/demo/README.md +++ b/demo/README.md @@ -42,7 +42,8 @@ uv run repub cleanup-media --config demo/repub.toml --dry-run With `--config`, cleanup scans `demo/out/feeds/` and honors any `REPUBLISHER_*_DIR` media directory overrides in the config. Remove `--dry-run` to delete old unreferenced media. The default retention window is 25 days; use -`--days N` to override it. +`--days N` to override it. Cleanup prints each matched path before the aggregate +summary. ## Local File Feed diff --git a/repub/cleanup.py b/repub/cleanup.py index 387c62a..950c81b 100644 --- a/repub/cleanup.py +++ b/repub/cleanup.py @@ -160,6 +160,10 @@ def cleanup_media( if path.resolve() in protected: continue result.matched_files += 1 + print( + f"media cleanup: matched path={path.resolve()} bytes={stat.st_size}", + file=output, + ) if dry_run: continue try: diff --git a/tests/test_cleanup.py b/tests/test_cleanup.py index c5d9748..87e9b3e 100644 --- a/tests/test_cleanup.py +++ b/tests/test_cleanup.py @@ -102,6 +102,29 @@ def test_cleanup_media_dry_run_reports_matches_without_deleting(tmp_path: Path) assert result.failures == 0 +def test_cleanup_media_lists_matched_files_before_summary(tmp_path: Path) -> None: + feeds_dir = tmp_path / "feeds" + old_file = feeds_dir / "demo" / "audio" / "old.mp3" + write_media(old_file, b"audio", age_days=40) + output = io.StringIO() + + result = cleanup_media( + feeds_dir=feeds_dir, + retention_days=25, + now=NOW, + dry_run=True, + output=output, + ) + + assert old_file.exists() + assert result.matched_files == 1 + output_lines = output.getvalue().splitlines() + assert ( + output_lines[0] == f"media cleanup: matched path={old_file.resolve()} bytes=5" + ) + assert "matched_files=1" in output_lines[-1] + + def test_cleanup_media_uses_configured_media_dirs(tmp_path: Path) -> None: feeds_dir = tmp_path / "feeds" demo_dir = feeds_dir / "demo"