Compare commits

...

2 Commits

Author SHA1 Message Date
3da2a4a252 fixed overrides not working 2026-03-06 17:47:30 +01:00
e8cf4b32f5 minor improvment in add to instance 2026-03-06 17:46:55 +01:00
2 changed files with 9 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
use anyhow::{Result, anyhow};
use anyhow::{Context, anyhow};
use log::{debug, trace};
use crate::types::{Game, Link, ModdedInstance, RootConfig};
@@ -11,7 +11,7 @@ pub fn activate_instance(
root_config: &RootConfig,
instance: &ModdedInstance,
target: impl AsRef<Path>,
) -> Result<()> {
) -> anyhow::Result<()> {
// TODO: Resolve game for instance config
let game = root_config
.games()
@@ -22,8 +22,9 @@ pub fn activate_instance(
resolved_links
.iter()
.try_for_each(|link| apply_link(link, target.as_ref()))?;
create_plugins_txt(instance, target.as_ref())?;
.try_for_each(|link| apply_link(link, &target))
.with_context(|| "Creating links")?;
create_plugins_txt(instance, target.as_ref()).with_context(|| "Creating Pluginx.txt")?;
Ok(())
}
@@ -35,7 +36,7 @@ fn resolve_links(
) -> anyhow::Result<Vec<Link>> {
let game_links = game.export_links()?;
let mod_links = resolve_link_for_instance(root_config, instance)?;
let overrides = instance.game_file_overrides().to_owned();
let overrides: Vec<Link> = instance.game_file_overrides().to_owned();
let mut map: HashMap<PathBuf, PathBuf> = HashMap::new();
@@ -103,8 +104,6 @@ fn link_file(target: &Path, link_name: &Path) -> Result<(), io::Error> {
}
fn create_symlink_for_file(target: &Path, link_name: &Path) -> io::Result<()> {
let absolute_path = fs::canonicalize(target)?;
trace!(
"Creating symlink at {} with target {}",
link_name.to_string_lossy(),
@@ -113,7 +112,7 @@ fn create_symlink_for_file(target: &Path, link_name: &Path) -> io::Result<()> {
#[cfg(unix)]
{
unix::fs::symlink(absolute_path, link_name)
unix::fs::symlink(target, link_name)
}
#[cfg(windows)]

View File

@@ -37,9 +37,9 @@ fn command_add(root_config: &RootConfig, instance_id: &str, mod_id: &str) -> any
.get_mod_by_id(mod_id)
.ok_or(anyhow!("Can't find mod in config"))?;
let files = files_to_install_mod(root_config, &instance, &mod_to_install)?;
let files = files_to_install_mod(root_config, &instance, mod_to_install)?;
insert_mod_to_instance(&mut instance, &mod_to_install, &files, 0);
insert_mod_to_instance(&mut instance, mod_to_install, &files, 0);
let path = &root_config.get_instance_config(instance_id).unwrap().path;
instance.save_to_file(path)?;