From bc342e8c64a1ef58b05540b4e62decc928f92815 Mon Sep 17 00:00:00 2001 From: dandels Date: Thu, 19 Dec 2024 13:22:24 +0200 Subject: [PATCH] Avoid creating load_order.txt upon initialization --- src/cache/installed.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/cache/installed.rs b/src/cache/installed.rs index ce519b2..8d37b25 100644 --- a/src/cache/installed.rs +++ b/src/cache/installed.rs @@ -51,16 +51,14 @@ impl Installed { } } } - let ret = Self { + Self { config, logger, metadata_index, mods: Arc::new(IndexMap::from_iter(installed).into()), has_changed: Arc::new(true.into()), archives_has_changed, - }; - ret.save_load_order().await; - ret + } } pub async fn get(&self, name: &str) -> Option<(String, ModDirectory)> { @@ -77,7 +75,8 @@ impl Installed { } pub async fn delete(&self, dir_name: &String) { - { // scope the lock so save_load_order() can reacquire it + { + // scope the lock so save_load_order() can reacquire it let mut mods_lock = self.mods.write().await; let path = self.config.install_dir().join(dir_name); if let Err(e) = fs::remove_dir_all(path).await { @@ -86,11 +85,10 @@ impl Installed { } if let Some(mod_dir) = mods_lock.shift_remove(dir_name) { if let ModDirectory::Nexus(im) = mod_dir { - let mfd = self - .metadata_index - .get_by_file_id(&im.file_id) - .await - .unwrap_or_else(|| panic!("{} should have been present in the metadata index.", &im.file_id)); + let mfd = + self.metadata_index.get_by_file_id(&im.file_id).await.unwrap_or_else(|| { + panic!("{} should have been present in the metadata index.", &im.file_id) + }); if mfd.remove_installed(dir_name).await { self.archives_has_changed.store(true, Ordering::Relaxed); } @@ -98,8 +96,9 @@ impl Installed { } self.has_changed.store(true, Ordering::Relaxed); } else { - self.logger - .log(format!("{dir_name} no longer exists. Please file a bug report if you did not just remove it.")); + self.logger.log(format!( + "{dir_name} no longer exists. Please file a bug report if you did not just remove it." + )); } } self.save_load_order().await;