fix: preserve instance state through launches and updates
This commit is contained in:
1 parent
3149b96971
commit
0d1cafcb10
14 files changed
+741
-94
No files matched your search
@@ -63,6 +63,56 @@ fn merge_keeps_replacement_when_a_dependency_is_also_an_update_root() {
|
||||
assert!(!merged.items[0].automatic_dependency);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn invalid_manifest_does_not_replace_installed_content() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let minecraft = temp.path().join("minecraft");
|
||||
let mods = minecraft.join("mods");
|
||||
tokio::fs::create_dir_all(&mods).await.unwrap();
|
||||
let old = mods.join("old.jar");
|
||||
tokio::fs::write(&old, b"original").await.unwrap();
|
||||
let manifest = temp.path().join("content.json");
|
||||
tokio::fs::write(&manifest, b"{bad JSON").await.unwrap();
|
||||
let selected = version(
|
||||
"new",
|
||||
"root",
|
||||
VersionType::Release,
|
||||
"2026-02-01",
|
||||
Vec::new(),
|
||||
);
|
||||
let plan = DependencyPlan {
|
||||
items: vec![PlannedInstall {
|
||||
provider: "modrinth".to_owned(),
|
||||
project_id: "root".to_owned(),
|
||||
title: "Root".to_owned(),
|
||||
version: selected.clone(),
|
||||
installed_path: Some(old.clone()),
|
||||
kind: ContentKind::Mod,
|
||||
destination: mods.clone(),
|
||||
provider_aliases: Vec::new(),
|
||||
required_dependencies: Vec::new(),
|
||||
automatic_dependency: false,
|
||||
cleanup_eligible: false,
|
||||
replacement: true,
|
||||
}],
|
||||
root_count: 1,
|
||||
optional_dependencies: 0,
|
||||
};
|
||||
|
||||
assert!(
|
||||
install(
|
||||
&provider(vec![selected]).registry(),
|
||||
&manifest,
|
||||
&minecraft,
|
||||
&plan
|
||||
)
|
||||
.await
|
||||
.is_err()
|
||||
);
|
||||
assert_eq!(tokio::fs::read(old).await.unwrap(), b"original");
|
||||
assert!(!mods.join("new.jar").exists());
|
||||
}
|
||||
|
||||
struct FakeProvider {
|
||||
versions: HashMap<String, VersionInfo>,
|
||||
compatible: HashMap<String, Vec<String>>,
|
||||
|
||||
@@ -5,6 +5,21 @@ use super::*;
|
||||
|
||||
struct NoopProgress;
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn linked_pack_contents_cannot_recurse_into_themselves() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let minecraft = temp.path().join("minecraft");
|
||||
let pack = minecraft.join("resourcepacks/unpacked");
|
||||
std::fs::create_dir_all(&pack).unwrap();
|
||||
std::fs::write(pack.join("pack.mcmeta"), b"pack").unwrap();
|
||||
std::os::unix::fs::symlink(&pack, pack.join("again")).unwrap();
|
||||
|
||||
let files = content_files(&minecraft).unwrap();
|
||||
assert_eq!(files.len(), 1);
|
||||
assert_eq!(directory_fingerprint_metadata(&pack).unwrap().size, 4);
|
||||
}
|
||||
|
||||
impl InventoryProgress for NoopProgress {
|
||||
fn set_sub_action(&self, _text: &str) {}
|
||||
|
||||
|
||||
Reference in new issue
Block a user