feat(drive): add read-only reporting commands#554
Conversation
Co-authored-by: Rohan Patnaik <rohan-patnaik@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bd64bb95d4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if opts.MaxItems > 0 && len(out) >= opts.MaxItems { | ||
| truncated = true | ||
| return out, truncated, nil |
There was a problem hiding this comment.
Apply --max after inventory sorting
drive inventory passes MaxItems into listDriveTree, which truncates during traversal before sortDriveInventory runs. This makes --sort ... --max N return only the first N discovered items (then sorted), not the top N for the requested sort key; in large/deep folders this can omit the actual largest/newest paths users asked for.
Useful? React with 👍 / 👎.
| out = append(out, resp.Files...) | ||
| if resp.NextPageToken == "" { | ||
| break | ||
| } | ||
| pageToken = resp.NextPageToken |
There was a problem hiding this comment.
Stop paginating children once max results is reached
Even when callers set a small --max, this function always fetches every page of a folder before returning children, so drive tree/drive inventory can still issue very large API reads and consume significant time/quota on big roots. Since --max is advertised as a hard cap, pagination should short-circuit as soon as the caller has enough items.
Useful? React with 👍 / 👎.
Summary
drive tree,drive du, anddrive inventoryTesting
go test -vet=off ./internal/cmd -run 'Test(SanitizeDriveName|JoinDrivePath|SummarizeDriveDu|ExecuteDriveTreeJSON)'\n-make build\n-make docs-commands\n-make ci\n-make docs-site\n- live Drive smoke onclawdbot@gmail.com: created temporary folder/subfolder/files, verifieddrive tree,drive inventory, anddrive duJSON output, then permanently deleted the temporary folder\n\nExtracted-from: feat: drive reporting/sync + contacts dedupe #116\nCo-authored-by: Rohan Patnaik rohan-patnaik@users.noreply.github.com