Add init file discovery in JobThreadContext and enhance script renaming logic

- Introduced a new method `find_init_file` to locate the first `init.*.luau` or `init.*.lua` file within a directory-format script folder.
- Updated the script renaming logic to handle directory-format scripts correctly by renaming the init file instead of the directory itself.
- Enhanced logging to provide warnings when no init file is found, improving debugging capabilities during class name changes.
- Adjusted related file handling to ensure proper file path management during script transitions.
This commit is contained in:
Joe 2026-02-05 18:46:43 -06:00
parent f4f07744c7
commit f38c96e12b
2 changed files with 111 additions and 45 deletions

View file

@ -2057,7 +2057,22 @@ impl ApiService {
.as_ref()
.context("Instance has no filesystem path")?;
let inst_path = instigating_source.path();
// ProjectNode instances are defined in the project file. Writing meta
// JSON to the project file path would corrupt it. Only filesystem-backed
// instances (InstigatingSource::Path) can have properties persisted.
let inst_path = match instigating_source {
InstigatingSource::Path(p) => p.as_path(),
InstigatingSource::ProjectNode { name, .. } => {
log::warn!(
"Cannot persist non-Source properties for instance '{}' (id: {:?}) — \
it is defined in a project file. Edit the project file directly.",
name,
update.id
);
return Ok(());
}
};
let class_name = instance.class_name();
let is_script = matches!(
class_name.as_str(),