Preserve and restore instigating source in Lua snapshot initialization

- Added logic to preserve the init script's instigating source before copying directory metadata, ensuring accurate file path references.
- Updated snapshot files to reflect the correct instigating source path for improved synchronization and consistency in tests.
This commit is contained in:
Joe 2026-01-24 10:04:47 -06:00
parent 730cdbda28
commit a7f36fab5e
3 changed files with 10 additions and 4 deletions

View file

@ -128,10 +128,16 @@ pub fn snapshot_lua_init(
let mut init_snapshot =
snapshot_lua(context, vfs, init_path, &dir_snapshot.name, script_type)?.unwrap();
// Preserve the init script's instigating_source (the actual file path)
// before copying the directory's metadata (which has the folder path)
let script_instigating_source = init_snapshot.metadata.instigating_source.take();
init_snapshot.children = dir_snapshot.children;
init_snapshot.metadata = dir_snapshot.metadata;
// The directory snapshot middleware includes all possible init paths
// so we don't need to add it here.
// Restore the init script's instigating_source so two-way sync writes
// to the actual file (e.g., init.luau) instead of the directory
init_snapshot.metadata.instigating_source = script_instigating_source;
DirectoryMetadata::read_and_apply_all(vfs, folder_path, &mut init_snapshot)?;

View file

@ -6,7 +6,7 @@ snapshot_id: "00000000000000000000000000000000"
metadata:
ignore_unknown_instances: false
instigating_source:
Path: /root
Path: /root/init.lua
relevant_paths:
- /root
- /root/init.lua

View file

@ -6,7 +6,7 @@ snapshot_id: "00000000000000000000000000000000"
metadata:
ignore_unknown_instances: false
instigating_source:
Path: /root
Path: /root/init.lua
relevant_paths:
- /root
- /root/init.lua