Skip to content

fix(table): include orphan file sizes in cleanup results#1412

Open
fallintoplace wants to merge 1 commit into
apache:mainfrom
fallintoplace:fix/clean-orphan-files-size
Open

fix(table): include orphan file sizes in cleanup results#1412
fallintoplace wants to merge 1 commit into
apache:mainfrom
fallintoplace:fix/clean-orphan-files-size

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

Summary

  • Add per-orphan file sizes to table orphan cleanup result as .
  • Populate file sizes during scan so retains size metadata, not just paths.
  • Map sizes into CLI output entries and render per-file size in text output.
  • Extend JSON output to always include and add regression tests for table/CLI.

Testing

  • go test ./...

@fallintoplace fallintoplace requested a review from zeroshade as a code owner July 5, 2026 14:07

@tanmayrauth tanmayrauth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, clean change and the table-level test covers the real path. Just a couple of small things around the CLI size lookup and the retained OrphanFileLocations field. Details inline.

Comment thread table/orphan_cleanup.go

type OrphanCleanupResult struct {
OrphanFileLocations []string
OrphanFiles []OrphanFile

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OrphanFiles []OrphanFile now carries the path and size for every orphan, while OrphanFileLocations []string above it carries just the paths — so the paths are duplicated across the two fields. Keeping OrphanFileLocations for backward compat is the right call, but could you add a one-line doc comment noting it's retained for compatibility and that OrphanFiles is the richer form? Otherwise a future reader has to diff the two to figure out why both
exist.

entries = append(entries, OrphanFileEntry{Path: f})
entries = append(entries, OrphanFileEntry{
Path: f,
SizeBytes: orphanSizes[f],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SizeBytes: orphanSizes[f] — in the non-dry-run branch files comes from result.DeletedFiles, but this size map is built from result.OrphanFiles. Any deleted path not present in OrphanFiles would silently render as 0 B rather than being caught. Today DeletedFiles ⊆ OrphanFiles so it's safe, but that's an implicit invariant — worth a short comment, or build the deleted entries by filtering OrphanFiles against the deleted set so the size always
stays attached to its path.

type OrphanFileEntry struct {
Path string `json:"path"`
SizeBytes int64 `json:"size_bytes,omitempty"`
SizeBytes int64 `json:"size_bytes"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropping omitempty means a genuinely 0-byte orphan now always serializes "size_bytes":0 instead of omitting the field. I think that's the right move for a stable output schema (and it matches PartitionStatsEntry.SizeBytes at line 146, which also has no omitempty) — just flagging it as an observable JSON change for anyone parsing the output.

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.

2 participants