Skip to content

Refactor watcher 3#1317

Merged
dajimenezriv-internxt merged 35 commits intomainfrom
refactor-watcher-3
Mar 25, 2026
Merged

Refactor watcher 3#1317
dajimenezriv-internxt merged 35 commits intomainfrom
refactor-watcher-3

Conversation

@dajimenezriv-internxt
Copy link
Copy Markdown
Contributor

@dajimenezriv-internxt dajimenezriv-internxt commented Mar 23, 2026

What

Refactor the watcher in C++. Now we are going to obtain the extended information from windows, which includes an internalId, size, mtime and ctime. We are going to send all events to javascript and there we are going to log them and group by internalId. The timeout to group is 2s. After that, if we are 2s without having any new event of an internalId we process that last event received with that internalId. This improve the issue of the move operation (it sends a delete event and after that a create event) and also the one of locked files (it sends a create event with size 0 and then many update events with size X until it reaches the final size Y). This second case it's more tricky to test since I don't know how much time can we expect from one update to another. I've added a test for that but probably we will need to continue improving this part.

@dajimenezriv-internxt dajimenezriv-internxt self-assigned this Mar 23, 2026
Base automatically changed from refactor-watcher-2 to main March 25, 2026 13:15
};

export async function onUnlink({ ctx, path, type }: Props) {
try {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just remove try catch here, we are already cathing in the previous one and logging the whole event.

};

export async function onAddDir({ ctx, path }: TProps) {
try {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just remove try catch here, we are already cathing in the previous one and logging the whole event.

};

export async function onChange({ ctx, path }: Props) {
try {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just remove try catch here, we are already cathing in the previous one and logging the whole event.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This line disappeared, so not only the try-catch

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True true, I thought it was only the things I marked as New.

await handleDehydrate({ ctx, path });
}
}
if (fileInfo.inSyncState === InSyncState.NotSync) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is new.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've added the tests for the new cases in a following PR.

}
}

async function handleNonPlaceholderFile(ctx: SyncContext, path: AbsolutePath) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is new.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
77.4% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@dajimenezriv-internxt dajimenezriv-internxt merged commit 2a24662 into main Mar 25, 2026
6 of 7 checks passed
@dajimenezriv-internxt dajimenezriv-internxt deleted the refactor-watcher-3 branch March 25, 2026 16:32
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