update disabled mods still
This commit is contained in:
parent
0f21171fe2
commit
66b4ab4e64
2 changed files with 72 additions and 0 deletions
|
|
@ -147,6 +147,10 @@ async fn check_bundle_updates_inner(
|
||||||
let mut hidden_dependency_keys_by_bundle: HashMap<String, HashSet<String>> = HashMap::new();
|
let mut hidden_dependency_keys_by_bundle: HashMap<String, HashSet<String>> = HashMap::new();
|
||||||
let mut hidden_explicit_keys_by_bundle: HashMap<String, HashSet<String>> = HashMap::new();
|
let mut hidden_explicit_keys_by_bundle: HashMap<String, HashSet<String>> = HashMap::new();
|
||||||
let mut shipped_keys_by_bundle: HashMap<String, HashSet<String>> = HashMap::new();
|
let mut shipped_keys_by_bundle: HashMap<String, HashSet<String>> = HashMap::new();
|
||||||
|
let mut user_disabled_versions: HashMap<
|
||||||
|
(String, String),
|
||||||
|
(String, crate::bundles::types::BundleFile),
|
||||||
|
> = HashMap::new();
|
||||||
|
|
||||||
for archive in &archives {
|
for archive in &archives {
|
||||||
let mut files_map = HashMap::new();
|
let mut files_map = HashMap::new();
|
||||||
|
|
@ -161,6 +165,12 @@ async fn check_bundle_updates_inner(
|
||||||
.get(&(archive.manifest.name.clone(), file.kind.package_id()))
|
.get(&(archive.manifest.name.clone(), file.kind.package_id()))
|
||||||
.copied();
|
.copied();
|
||||||
if !crate::bundles::effective_enabled(file, user_override) {
|
if !crate::bundles::effective_enabled(file, user_override) {
|
||||||
|
if user_override == Some(OverrideType::Disabled) {
|
||||||
|
user_disabled_versions.insert(
|
||||||
|
(archive.manifest.name.clone(), file.kind.bundle_key()),
|
||||||
|
(file.kind.bundle_version_id(), file.clone()),
|
||||||
|
);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let key = file.kind.bundle_key();
|
let key = file.kind.bundle_key();
|
||||||
|
|
@ -271,6 +281,18 @@ async fn check_bundle_updates_inner(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if matched_target.is_none() {
|
||||||
|
matched_target = user_disabled_versions
|
||||||
|
.get(&(bundle_name.clone(), installed_key.clone()))
|
||||||
|
.map(|(new_version_id, new_file)| {
|
||||||
|
(
|
||||||
|
bundle_name.clone(),
|
||||||
|
new_version_id.clone(),
|
||||||
|
new_file.clone(),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if let Some((resolved_bundle_name, new_version_id, new_file)) = matched_target {
|
if let Some((resolved_bundle_name, new_version_id, new_file)) = matched_target {
|
||||||
if installed_version_id != &new_version_id {
|
if installed_version_id != &new_version_id {
|
||||||
updates_available.push(BundlePackageUpdate {
|
updates_available.push(BundlePackageUpdate {
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,56 @@ async fn user_disabled_mod_is_not_treated_as_a_removal() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn user_disabled_mod_still_takes_updates() {
|
||||||
|
let state = oneclient_core::dev::ephemeral_state().await.unwrap();
|
||||||
|
let mut newer = managed_file(true);
|
||||||
|
if let BundleFileKind::Managed {
|
||||||
|
version_id, sha1, ..
|
||||||
|
} = &mut newer.kind
|
||||||
|
{
|
||||||
|
*version_id = "v2".to_string();
|
||||||
|
*sha1 = "cccccccccccccccccccccccccccccccccccccccc".to_string();
|
||||||
|
}
|
||||||
|
oneclient_core::dev::seed_bundle_archive(&state, manifest(vec![newer]))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
let cluster_id = cluster_with_tracked_mod(&state).await;
|
||||||
|
|
||||||
|
artifact_dao::update_cluster_artifact(&state.services.db, cluster_id, HASH, "sodium.jar", 0)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
bundle_dao::save_override(
|
||||||
|
&state.services.db,
|
||||||
|
cluster_id,
|
||||||
|
BUNDLE,
|
||||||
|
PROJECT_ID,
|
||||||
|
OverrideType::Disabled,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let check = check_bundle_updates(
|
||||||
|
cluster_id,
|
||||||
|
state.bundles.as_ref(),
|
||||||
|
&state.services.content(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
check
|
||||||
|
.updates_available
|
||||||
|
.iter()
|
||||||
|
.map(|u| u.new_version_id.as_str())
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
["v2"],
|
||||||
|
"a user-disabled mod must still be offered the newer version"
|
||||||
|
);
|
||||||
|
assert!(check.removals_available.is_empty());
|
||||||
|
assert!(check.additions_available.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn live_bundle_takes_on_new_catalog_files() {
|
async fn live_bundle_takes_on_new_catalog_files() {
|
||||||
let state = oneclient_core::dev::ephemeral_state().await.unwrap();
|
let state = oneclient_core::dev::ephemeral_state().await.unwrap();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue