Fix change_processor crash when path is a directory during two-way sync#1228
Open
adv-andrew wants to merge 1 commit intorojo-rbx:masterfrom
Open
Fix change_processor crash when path is a directory during two-way sync#1228adv-andrew wants to merge 1 commit intorojo-rbx:masterfrom
adv-andrew wants to merge 1 commit intorojo-rbx:masterfrom
Conversation
The change processor was crashing because fs::write and fs::remove_file were being called on directory paths instead of file paths. This happens with init scripts where the instigating source points to the directory instead of the init file. Added resolve_init_path to find the actual init file in a directory, and used remove_dir_all for directory removal. Fixes rojo-rbx#1206
48689df to
4038990
Compare
Dekkonot
requested changes
Feb 19, 2026
Member
Dekkonot
left a comment
There was a problem hiding this comment.
This needs a changelog entry. There's instructions for that in CHANGELOG.md.
| InstigatingSource::Path(path) => { | ||
| if let Some(Variant::String(value)) = changed_value { | ||
| fs::write(path, value).unwrap(); | ||
| match resolve_init_path(path) { |
Member
There was a problem hiding this comment.
You should be able to use snapshot_middleware::get_dir_middleware here instead. You'll have to change the visibility of that function but I'd prefer that to recreating the same behavior of finding an init path. Keeps things in one place and all that.
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.
Fixes #1206
I was running into the same crash described in the issue where Rojo would panic during two-way sync. After looking into it, the problem is that
fs::writeandfs::remove_fileinhandle_tree_eventcan receive a directory path instead of a file path when dealing with init scripts.What I did:
resolve_init_paththat checks if the path is a directory and if so, looks for the init file inside it (init.lua, init.luau, etc.)remove_dir_allinstead ofremove_fileI tried to match the same init file priority order that's used in
snapshot_middleware/mod.rs.Let me know if there's anything I should change!