feat(content): add managed content metadata layout
This commit is contained in:
1 parent
a05b030862
commit
fbf8142ea0
46 files changed
+2404
-166
No files matched your search
@@ -1,5 +1,5 @@
|
||||
// integration tests for the public content-scanner APIs: shaders, worlds,
|
||||
// and resource packs. each scanner walks an instance's .minecraft subdir
|
||||
// and resource packs. each scanner walks an instance's minecraft subdir
|
||||
// and returns ContentEntry rows; shape varies slightly per content type
|
||||
// (worlds are directories only, packs and shaders accept .zip or dir, etc.).
|
||||
|
||||
@@ -10,7 +10,7 @@ use rmcl::instance::content::shaders::scan_shaders;
|
||||
use rmcl::instance::content::worlds::scan_worlds;
|
||||
|
||||
fn setup_subdir(tmp: &Path, instance: &str, sub: &str) -> PathBuf {
|
||||
let dir = tmp.join(instance).join(".minecraft").join(sub);
|
||||
let dir = tmp.join(instance).join("minecraft").join(sub);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
dir
|
||||
}
|
||||
|
||||
+25
-19
@@ -73,9 +73,9 @@ fn fake_java(tmp: &TempDir, major: u32) -> String {
|
||||
}
|
||||
|
||||
// builds the on-disk layout that build_launch_invocation expects:
|
||||
// <tmp>/instances/<name>/.minecraft/ (instance dir, created empty)
|
||||
// <tmp>/instances/<name>/minecraft/ (instance dir, created empty)
|
||||
// <tmp>/meta/versions/<game_version>/meta.json
|
||||
// <tmp>/meta/loader-profiles/ (created empty)
|
||||
// <tmp>/meta/cache/loaders/profiles/ (created empty)
|
||||
// <tmp>/meta/libraries/ (created empty)
|
||||
struct Fixture {
|
||||
_tmp: TempDir,
|
||||
@@ -89,12 +89,12 @@ impl Fixture {
|
||||
let instances_dir = tmp.path().join("instances");
|
||||
let meta_dir = tmp.path().join("meta");
|
||||
|
||||
let instance_minecraft = instances_dir.join(instance_name).join(".minecraft");
|
||||
let instance_minecraft = instances_dir.join(instance_name).join("minecraft");
|
||||
std::fs::create_dir_all(&instance_minecraft).unwrap();
|
||||
|
||||
std::fs::create_dir_all(meta_dir.join("libraries")).unwrap();
|
||||
std::fs::create_dir_all(meta_dir.join("loader-profiles")).unwrap();
|
||||
let version_dir = meta_dir.join("versions").join(game_version);
|
||||
std::fs::create_dir_all(meta_dir.join("cache/minecraft/libraries")).unwrap();
|
||||
std::fs::create_dir_all(meta_dir.join("cache/loaders/profiles")).unwrap();
|
||||
let version_dir = meta_dir.join("cache/minecraft/versions").join(game_version);
|
||||
std::fs::create_dir_all(&version_dir).unwrap();
|
||||
std::fs::write(
|
||||
version_dir.join("meta.json"),
|
||||
@@ -111,7 +111,7 @@ impl Fixture {
|
||||
|
||||
fn write_loader_profile(&self, filename: &str, content: serde_json::Value) {
|
||||
std::fs::write(
|
||||
self.meta_dir.join("loader-profiles").join(filename),
|
||||
self.meta_dir.join("cache/loaders/profiles").join(filename),
|
||||
serde_json::to_vec_pretty(&content).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -120,7 +120,7 @@ impl Fixture {
|
||||
fn instance_libraries_dir(&self, instance_name: &str) -> PathBuf {
|
||||
self.instances_dir
|
||||
.join(instance_name)
|
||||
.join(".minecraft")
|
||||
.join("minecraft")
|
||||
.join("libraries")
|
||||
}
|
||||
}
|
||||
@@ -209,7 +209,11 @@ async fn vanilla_modern_builds_complete_invocation() {
|
||||
assert_eq!(inv.main_class, "net.minecraft.client.main.Main");
|
||||
assert!(inv.extra_args.is_empty());
|
||||
|
||||
let expected_natives = fx.meta_dir.join("versions").join("1.20.1").join("natives");
|
||||
let expected_natives = fx
|
||||
.meta_dir
|
||||
.join("cache/minecraft/versions")
|
||||
.join("1.20.1")
|
||||
.join("natives");
|
||||
assert!(
|
||||
inv.jvm_args
|
||||
.iter()
|
||||
@@ -225,16 +229,18 @@ async fn vanilla_modern_builds_complete_invocation() {
|
||||
inv.jvm_args
|
||||
);
|
||||
|
||||
// working_dir is <instances_dir>/<name>/.minecraft
|
||||
// working_dir is <instances_dir>/<name>/minecraft
|
||||
assert_eq!(
|
||||
inv.working_dir,
|
||||
fx.instances_dir.join("v1").join(".minecraft")
|
||||
fx.instances_dir.join("v1").join("minecraft")
|
||||
);
|
||||
// classpath = the one vanilla lib + the vanilla client jar
|
||||
let slf4j = fx
|
||||
.meta_dir
|
||||
.join("libraries/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar");
|
||||
let client_jar = fx.meta_dir.join("versions/1.20.1/1.20.1.jar");
|
||||
.join("cache/minecraft/libraries/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar");
|
||||
let client_jar = fx
|
||||
.meta_dir
|
||||
.join("cache/minecraft/versions/1.20.1/1.20.1.jar");
|
||||
assert!(inv.classpath.contains(&slf4j));
|
||||
assert!(inv.classpath.contains(&client_jar));
|
||||
}
|
||||
@@ -422,12 +428,12 @@ async fn fabric_implicit_inheritsfrom_resolves() {
|
||||
"net.fabricmc.loader.impl.launch.knot.KnotClient"
|
||||
);
|
||||
// both fabric-loader and vanilla slf4j must appear on the merged classpath
|
||||
let fabric_loader = fx
|
||||
.meta_dir
|
||||
.join("libraries/net/fabricmc/fabric-loader/0.15.0/fabric-loader-0.15.0.jar");
|
||||
let fabric_loader = fx.meta_dir.join(
|
||||
"cache/minecraft/libraries/net/fabricmc/fabric-loader/0.15.0/fabric-loader-0.15.0.jar",
|
||||
);
|
||||
let slf4j = fx
|
||||
.meta_dir
|
||||
.join("libraries/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar");
|
||||
.join("cache/minecraft/libraries/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar");
|
||||
assert!(
|
||||
inv.classpath.contains(&fabric_loader),
|
||||
"fabric-loader missing from classpath: {:?}",
|
||||
@@ -631,8 +637,8 @@ async fn meta_not_found_returns_error() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let instances_dir = tmp.path().join("instances");
|
||||
let meta_dir = tmp.path().join("meta");
|
||||
std::fs::create_dir_all(instances_dir.join("ghost").join(".minecraft")).unwrap();
|
||||
std::fs::create_dir_all(meta_dir.join("versions")).unwrap();
|
||||
std::fs::create_dir_all(instances_dir.join("ghost").join("minecraft")).unwrap();
|
||||
std::fs::create_dir_all(meta_dir.join("cache/minecraft/versions")).unwrap();
|
||||
|
||||
let config = make_config("ghost", "1.20.1", ModLoader::Vanilla);
|
||||
let err = build_launch_invocation(&config, &instances_dir, &meta_dir, &test_auth())
|
||||
|
||||
+5
-5
@@ -170,7 +170,7 @@ async fn download_libraries_writes_artifact_to_meta_dir() {
|
||||
|
||||
let written = tmp
|
||||
.path()
|
||||
.join("libraries/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar");
|
||||
.join("cache/minecraft/libraries/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar");
|
||||
assert!(written.exists(), "expected library file at {written:?}");
|
||||
let contents = std::fs::read(&written).unwrap();
|
||||
assert_eq!(contents, b"jar-bytes");
|
||||
@@ -193,7 +193,7 @@ async fn download_libraries_skips_when_destination_exists() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let existing = tmp
|
||||
.path()
|
||||
.join("libraries/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar");
|
||||
.join("cache/minecraft/libraries/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar");
|
||||
std::fs::create_dir_all(existing.parent().unwrap()).unwrap();
|
||||
std::fs::write(&existing, b"already there").unwrap();
|
||||
|
||||
@@ -240,11 +240,11 @@ async fn download_assets_from_writes_index_and_assets() {
|
||||
.await
|
||||
.expect("download_assets_from");
|
||||
|
||||
let index_path = tmp.path().join("assets/indexes/5.json");
|
||||
let index_path = tmp.path().join("cache/minecraft/assets/indexes/5.json");
|
||||
assert!(index_path.exists(), "index file missing");
|
||||
let asset_path = tmp
|
||||
.path()
|
||||
.join("assets/objects/ab/ab1234567890abcdef1234567890abcdef123456");
|
||||
.join("cache/minecraft/assets/objects/ab/ab1234567890abcdef1234567890abcdef123456");
|
||||
assert!(asset_path.exists(), "asset file missing");
|
||||
assert_eq!(std::fs::read(&asset_path).unwrap(), b"asset-bytes");
|
||||
}
|
||||
@@ -269,7 +269,7 @@ async fn download_assets_writes_index_when_objects_is_empty() {
|
||||
.await
|
||||
.expect("download_assets index-only");
|
||||
|
||||
let index_path = tmp.path().join("assets/indexes/5.json");
|
||||
let index_path = tmp.path().join("cache/minecraft/assets/indexes/5.json");
|
||||
assert!(
|
||||
index_path.exists(),
|
||||
"expected asset index at {index_path:?}"
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
|
||||
use rmcl::instance::screenshots::scan_screenshots;
|
||||
|
||||
fn setup_screenshots_dir(tmp: &Path, instance: &str) -> PathBuf {
|
||||
let dir = tmp.join(instance).join(".minecraft").join("screenshots");
|
||||
let dir = tmp.join(instance).join("minecraft").join("screenshots");
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
dir
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user