Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add track file ids option to fs watcher #912

Closed
wants to merge 1 commit into from

Conversation

dfaust
Copy link
Contributor

@dfaust dfaust commented Jan 20, 2024

Add trackFileIds to the DebouncedWatchOptions.

When enabled, the fs watcher gets the filesystem ids of all watched files and keeps them in memory in order to be able to stitch together rename events on Windows and MacOS.

When disabled, users may receive events like:

rename /home/user/file.txt
rename /home/user/file-backup.txt

When enabled, the events would be merged into:

rename /home/user/file.txt to /home/user/file-backup.txt

The feature is disabled by default. But we might want to enable it by default, as it is pretty useful.
Also, we may want to automatically disable it on Linux, since inotify emits a cookie for rename events, so notify-debouncer-full handles them correctly already.

I didn't add a .changes file because notify-debouncer-full is new for the v2 release.

@dfaust dfaust requested a review from a team as a code owner January 20, 2024 13:40
@FabianLars
Copy link
Member

Thanks for the follow-up pr!

The feature is disabled by default. But we might want to enable it by default, as it is pretty useful.
Also, we may want to automatically disable it on Linux, since inotify emits a cookie for rename events, so notify-debouncer-full handles them correctly already.

Just to double check. macos and windows with the feature enabled would behave the same as linux without it?
And what happens if you do enable it on Linux?

@dfaust
Copy link
Contributor Author

dfaust commented Jan 20, 2024

macos and windows with the feature enabled would behave the same as linux without it?

Correct!

And what happens if you do enable it on Linux?

It will scan the file ids and keep them in memory, but won't actually change the emitted events.

@FabianLars
Copy link
Member

Cool, thanks! Does it even makes sense to have it optional in the first place then?
I'm afraid that the platform difference would cause more issues than the value the config would bring, especially for frontend heavy users that aren't used to platform differences.

@dfaust
Copy link
Contributor Author

dfaust commented Jan 20, 2024

Good question. I guess 99% of users would want this feature enabled, because it makes things easier.
But it comes at a small cost. Then again, the only scenario in which disabling it would make a difference is if you were watching a huge number of files and weren't interested in rename events.

I wouldn't mind removing the option for now. We can add it back if needed.
Also, there is still some potential to save memory in the notify-debouncer-full crate. The file ids are currently stored as a hashmap with full paths for every file.

Btw. I was thinking about the track-file-ids feature not being needed on Linux, and I think will disable it on Linux by default directly in the notify-debouncer-full crate.

@FabianLars
Copy link
Member

Yeah, imo removing the option is fine. The IPC's performance hit probably makes the cost unnoticable anyway 😅
But i'd like to hear @amrbashir's opinion on that matter too.

@amrbashir
Copy link
Member

I'd go with consistency on all platforms first and provide the option to disable this, i.e add a feature flag and enable it by default.

@dfaust
Copy link
Contributor Author

dfaust commented Jan 23, 2024

This PR has been made obsolete by a change in the notify-debouncer-full create (notify-rs/notify#557), so I'm closing it now.
I will create a new one, once a new version of notify-debouncer-full has been released.
The new version enables file id tracking by default on Windows and MacOS. It can still be disabled, but I tend towards not exposing that option in Tauri (for now). As long as performance is not critical, it simplifies the usage.

@amrbashir: To be clear, the file id tracking fixes an inconsistency between Windows and MacOS on the one side and Linux on the other.

@dfaust dfaust closed this Jan 23, 2024
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.

3 participants