horizon-server: find game files prepared without sounds

init and run looked for asset-index.json to recognise a prepared folder,
but horizon-prepare writes that file only with the optional sounds
(`horizon-prepare sounds`). A server prepared the usual way, without
sounds, was never found: init said "no prepared game files" and listed
the folder that held them. They are now recognised by
horizon-resources.json, the manifest every preparation writes and the
one the game itself reads.

Found by installing v2026.10.18.15 with install.sh on the Mac mini and
preparing from the release folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-18 17:50:52 +02:00
parent 163bcdd604
commit 44fba3bf9d
+18 -2
View File
@@ -65,12 +65,13 @@ pub fn resource_candidates(config: &Config, dir: &Path, program: Option<&Path>)
out
}
/// The prepared game files: a folder holding the asset index `horizon-prepare` writes.
/// The prepared game files: a folder holding the manifest every `horizon-prepare` run writes
/// (`asset-index.json` comes only with the optional sounds, which a server doesn't need).
pub fn resources(config: &Config, dir: &Path, program: Option<&Path>) -> Result<PathBuf, String> {
let candidates = resource_candidates(config, dir, program);
candidates
.iter()
.find(|d| d.join("asset-index.json").is_file())
.find(|d| d.join("horizon-resources.json").is_file())
.cloned()
.ok_or_else(|| {
let tried: Vec<String> = candidates
@@ -179,4 +180,19 @@ mod tests {
[PathBuf::from("/data/res")]
);
}
#[test]
fn resources_prepared_without_sounds_are_found() {
let root = std::env::temp_dir().join(format!("horizon-server-res-{}", std::process::id()));
let prepared = root.join(".local/horizon-client/26.3");
std::fs::create_dir_all(&prepared).unwrap();
let program = root.join("horizon-client");
let config = Config::default();
let server = root.join("server");
assert!(resources(&config, &server, Some(&program)).is_err());
// What `horizon-prepare` writes on every run; no asset index without `horizon-prepare sounds`.
std::fs::write(prepared.join("horizon-resources.json"), "{}").unwrap();
assert_eq!(resources(&config, &server, Some(&program)), Ok(prepared));
std::fs::remove_dir_all(&root).unwrap();
}
}