Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/installers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn install(
WeiduBatchedInstallOrder::new(components_to_be_installed)
};
for components in mods_to_be_installed.into_iter() {
let last_mod = if let Some(weidu_mod) = components.last() {
let first_mod = if let Some(weidu_mod) = components.first() {
weidu_mod
} else {
continue;
Expand All @@ -114,7 +114,7 @@ fn install(
if let Some(entry) = mod_folder_cache.get::<OsString>(&components.log_file_name().into()) {
entry.to_path_buf()
} else {
let entry = match search_or_download(options, last_mod) {
let entry = match search_or_download(options, first_mod) {
Ok(value) => value,
Err(err) if options.never_abort => {
log::error!("{:?}", err);
Expand All @@ -123,26 +123,26 @@ fn install(
},
Err(err) => return Err(err),
};
mod_folder_cache.insert(last_mod.tp_file.clone().into(), entry.clone());
mod_folder_cache.insert(first_mod.tp_file.clone().into(), entry.clone());
entry
};

log::debug!("Found mod folder {mod_folder:?}, for component {components:?}");

if options.overwrite {
delete_folder(game_directory.join(&last_mod.name))?;
delete_folder(game_directory.join(&first_mod.name))?;
}

if !mod_folder_present_in_game_directory(game_directory, &last_mod.name) {
if !mod_folder_present_in_game_directory(game_directory, &first_mod.name) {
log::info!(
"Copying mod directory, from {:?} to, {:?}",
mod_folder,
game_directory.join(&last_mod.name)
game_directory.join(&first_mod.name)
);
copy_folder(mod_folder, game_directory.join(&last_mod.name), false)?;
copy_folder(mod_folder, game_directory.join(&first_mod.name), false)?;
}
log::info!("Installing mod {:?}", &components);
let bg1_game_directory = if last_mod
let bg1_game_directory = if first_mod
.component_name
.to_lowercase()
.eq("eet core (resource importation)")
Expand All @@ -165,7 +165,7 @@ fn install(
) {
Ok(WeiduExitStatus::Success) if options.check_last_installed && !options.never_abort => {
if let Ok(last_installed) = get_last_installed(game_directory) {
if last_installed.ne(last_mod) {
if last_installed.ne(first_mod) {
return Err(format!(
"Last installed {last_installed:?} does not match component installed: {components:?}"
)
Expand Down
3 changes: 3 additions & 0 deletions src/weidu/batched_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ impl WeiduBatchedComponents {
self.0.push(component);
}
}
pub(crate) fn first(&self) -> Option<&WeiduComponent> {
self.0.first()
}
pub(crate) fn last(&self) -> Option<&WeiduComponent> {
self.0.last()
}
Expand Down
6 changes: 5 additions & 1 deletion src/weidu/install_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ pub(crate) struct WeiduBatchedInstallOrder(Vec<WeiduBatchedComponents>);

impl WeiduBatchedInstallOrder {
pub(crate) fn new(components: WeiduBatchedComponents) -> Self {
Self(vec![components])
let mut out: Vec<WeiduBatchedComponents> = vec![];
for component in components.into_iter() {
out.push(vec![component.clone()].into());
}
Self(out)
}
pub(crate) fn batch(components: WeiduBatchedComponents) -> Result<Self, Box<dyn Error>> {
let mut out: Vec<WeiduBatchedComponents> = vec![];
Expand Down