Skip to content

fix: prevent snapshot from tracking large files - #12185

Closed
goniz wants to merge 10 commits into
anomalyco:devfrom
goniz:snapshot-filter-bigf
Closed

fix: prevent snapshot from tracking large files#12185
goniz wants to merge 10 commits into
anomalyco:devfrom
goniz:snapshot-filter-bigf

Conversation

@goniz

@gonizgoniz commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

This PR prevents the Snapshot.track() flow from adding (untracked) big files into the snapshot system (git).

It changes the code to first do git add -N . which stage the files without content.
Next it iterates over the staged files to find any files larger then defined threshold (1 gig). unstages them AND adds them to $gitdir/info/exclude to prevent them from getting staged again.
Finally it calls git add -- $stagedFiles to stage the files content as well.

To handle existing bloated snapshot dirs, the cleanup method was updated to detect if any existing object blob is bigger then threshold -> nukes the whole snapshot dir.
Leaving the big files causes the git gc --prune process to blow up on memory and hog the system.

Additionally, this PR cleans up the Snapshot code a bit.

Don't be scared from the lines added, I've added tests too 😆

Fixes#6845

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on the search results, I found one potentially related PR:

Related PR:

You should verify if PR #10628 has already been merged or if it addresses the same root cause as PR #12185.

Comment threadpackages/opencode/src/snapshot/index.ts Outdated
@goniz
gonizforce-pushed the snapshot-filter-bigf branch 4 times, most recently from 3f7b472 to 026c6eeCompareFebruary 11, 2026 18:34
@gonizgoniz changed the title feat: filter out 1GB+ files from snapshotfix: prevent snapshot from trackibg large filesFeb 14, 2026
@gonizgoniz changed the title fix: prevent snapshot from trackibg large filesfix: prevent snapshot from tracking large filesFeb 15, 2026
@goniz
gonizforce-pushed the snapshot-filter-bigf branch 4 times, most recently from 72f72fb to 5bbccecCompareFebruary 17, 2026 17:50
@goniz
gonizforce-pushed the snapshot-filter-bigf branch from 5bbccec to c28f3edCompareFebruary 24, 2026 14:00

@gonizgoniz left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Self review 😄

Comment threadpackages/opencode/src/snapshot/index.ts Outdated
Comment threadpackages/opencode/src/snapshot/index.ts Outdated
Comment threadpackages/opencode/src/snapshot/index.ts
Comment threadpackages/opencode/src/snapshot/index.ts
Comment threadpackages/opencode/src/snapshot/index.ts Outdated
Comment threadpackages/opencode/src/util/stream.ts Outdated
@goniz
gonizforce-pushed the snapshot-filter-bigf branch from c28f3ed to 70022bcCompareFebruary 24, 2026 15:51
@thdxr

Copy link
Copy Markdown
Member

sorry we didn't see this earlier. we did a similar fix (had to be a bit different because running a git command with lots of files fails on windows)

@thdxrthdxr closed this Mar 25, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HUGE snapshot folder

2 participants

@goniz@thdxr