From f2f5e01a8753004c242a07ca6aac0de94773757f Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 5 Feb 2026 22:05:56 -0600 Subject: [PATCH] Enhance path handling for init files in ApiService - Updated logic in `api.rs` to correctly handle cases where existing paths are init files, ensuring that children are placed in the appropriate directory. - Improved clarity in comments to explain the handling of init files and their relationship to directory structure, contributing to better maintainability of the code. --- src/web/api.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/web/api.rs b/src/web/api.rs index 187e070b..2dda6040 100644 --- a/src/web/api.rs +++ b/src/web/api.rs @@ -869,6 +869,15 @@ impl ApiService { if !added.children.is_empty() { let children_dir = if existing_path.is_dir() { existing_path.to_path_buf() + } else if existing_path + .file_name() + .and_then(|n| n.to_str()) + .map_or(false, |n| n.starts_with("init.")) + { + // existing_path is an init file (e.g., DirFoo/init.luau). + // The instance is already in directory format -- children go + // into the same directory that contains the init file. + existing_path.parent().unwrap_or(existing_path).to_path_buf() } else { // Standalone scripts cannot have children in Rojo's file format. // We need to convert from standalone (e.g., MyScript.server.luau)