Only stop when more than x files change in the project compared to more than x files exist#121
Merged
joeldierkes merged 2 commits intomainfrom Jan 20, 2026
Merged
Conversation
Contributor
|
strange naming but looks good |
aamir-s18
approved these changes
Jan 20, 2026
**You were correct!** The previous behavior checked `repoFiles.length` (total files in the folder) instead of files that actually need to be synced.
### Changes Made
1. **`src/lib/utils.ts:27-35`** - Updated `MaxFileCountExceededError` message to say "Files to sync" instead of "File count"
2. **`src/lib/utils.ts:300-326`** - Added logic to calculate `filesToPotentiallyUpload` which counts only files that:
- Are new (not in store)
- Have changed (mtime is newer than stored mtime)
- Don't exceed max file size
Then the check is:
```typescript
const filesToSync = filesToPotentiallyUpload.length + filesToDelete.length;
if (config && filesToSync > config.maxFileCount) {
throw new MaxFileCountExceededError(filesToSync, config.maxFileCount);
}
```
### Behavior Change
| Scenario | Before | After |
|----------|--------|-------|
| 2000 files total, 10 need syncing, limit=1000 | ❌ Error (2000 > 1000) | ✅ Passes (10 < 1000) |
| 500 files total, 1500 deleted in store, limit=1000 | ✅ Passes (500 < 1000) | ❌ Error (1500 > 1000) |
| 100 new files + 50 deleted, limit=1000 | ✅ Passes | ✅ Passes (150 < 1000) |
The new behavior is more practical - it protects against accidentally syncing too many changes in one operation while allowing large codebases that are already synced to continue working.
1. **Line 208**: Changed description from "limit uploads to directories with 5000 files or fewer" to "limit sync to 5000 changed files or fewer" 2. **Line 232**: Changed comment from "Maximum number of files to upload" to "Maximum number of files to sync (upload/delete) per operation" 3. **Line 274**: Changed description from "Maximum number of files to upload" to "Maximum number of files to sync per operation" - Updated JSDoc comment to reflect that the limit applies to files that need syncing, not total files in the folder Updated 4 test assertions to match the new error message format: - Line 404: `File count (5)` → `Files to sync (5)` - Line 436: `File count (4)` → `Files to sync (4)` - Line 453: `File count (4)` → `Files to sync (4)` - Line 470: `File count (4)` → `Files to sync (4)` - All instances of `No files were uploaded` → `No files were synced`
e27cc12 to
0a1f95c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rn mgrep watch stops when more than x files exist in the folder. Let's change that so that mgrep stops when more than x files need to be uploaded/deleted.
Also check if that is really the current behavior.
Note
Implements file count limiting based on actual sync workload rather than total repo files.
initialSyncnow precomputesfilesToPotentiallyUpload(size-filtered, mtime-checked) andfilesToDelete, sums them asfilesToSync, and throwsMaxFileCountExceededErrorwhen exceedingconfig.maxFileCountFiles to sync (X) exceeds the maximum allowed (Y). No files were synced.and updates all tests accordinglyREADME.mdand config JSDoc to clarifymaxFileCountapplies to files to sync per operation (upload/delete), and example CLI/env var descriptionsWritten by Cursor Bugbot for commit 0a1f95c. This will update automatically on new commits. Configure here.