Skip to content

Commit afff4fc

Browse files
committed
Make --full clear the dump directory before writing
Instead of rewriting files in place, --full now removes the entire dump directory first, ensuring stale files from old runs are cleaned up.
1 parent 11e184d commit afff4fc

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

  • src/glab_discussion/commands

src/glab_discussion/commands/read.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ def run(args: argparse.Namespace) -> None:
6060
# 8. Dump mode
6161
tmp = Path(tempfile.gettempdir())
6262
output_dir = tmp / "glab-discussion" / sanitize_path_part(ctx.hostname) / f"mr-{ctx.mr_iid}"
63+
force_full = args.full
64+
65+
if force_full and output_dir.exists():
66+
import shutil
67+
68+
shutil.rmtree(output_dir)
69+
6370
output_dir.mkdir(parents=True, exist_ok=True)
6471

6572
meta_path = output_dir / ".meta.json"
@@ -72,17 +79,15 @@ def run(args: argparse.Namespace) -> None:
7279
new_files: list[str] = []
7380
updated_files: list[str] = []
7481

75-
force_full = args.full
76-
7782
for discussion in discussions:
7883
filename = _discussion_filename(discussion, user_cache)
7984
max_ts = discussion.max_timestamp
8085
did = discussion.id
8186

8287
new_meta[did] = {"max_timestamp": max_ts, "filename": filename}
8388

84-
# Check if we can skip
85-
if not force_full and did in old_meta:
89+
# Check if we can skip (--full always writes since dir was cleared)
90+
if did in old_meta:
8691
old_entry = old_meta[did]
8792
if old_entry.get("max_timestamp") == max_ts:
8893
continue

0 commit comments

Comments
 (0)