From 2874d290ebeb682594a97e5d4db20424f09c9c47 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Mon, 1 Mar 2021 21:49:32 -0600 Subject: [PATCH] fix: ensure archive doctests pass --- client/src/archive.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/client/src/archive.rs b/client/src/archive.rs index 722673a..13d480d 100644 --- a/client/src/archive.rs +++ b/client/src/archive.rs @@ -74,8 +74,12 @@ impl Archive { /// # Examples /// ``` /// # use crate::client::archive::Archive; - /// let archive = Archive::try_default() - /// archive.track_game("/home/user/Documents/generic_company/generic_game/save_folder") + /// let mut archive = Archive::try_default().unwrap(); + /// let game_save_path = "/home/user/Documents/generic_company/generic_game/save_folder"; + /// match archive.track_game(game_save_path) { + /// Ok(_) => println!("Save Sync is now tracking {}", game_save_path), + /// Err(err) => eprintln!("Failed to track {}: {:?}", game_save_path, err) + /// }; /// ``` pub fn track_game>(&mut self, path: P) -> Result<(), GameTrackError> { let game_save_loc = self.get_game_save_files(path, None)?; @@ -150,7 +154,11 @@ impl Archive { /// let drop_res = archive.drop_game("/home/user/Documents/generic_company/generic_game/save_folder"); /// ``` pub fn drop_game>(&mut self, path: P) -> Result<(), GameDropError> { - unimplemented!() + self.tracked_games + .retain(|game| game.original_path != path.as_ref()); + + // TODO: Remove backup copy of game save location on disk + Ok(()) } /// Removes a game from the list of tracked games using the game's friendly name @@ -167,7 +175,13 @@ impl Archive { /// let drop_res = archive.drop_game("raging_loop"); /// ``` pub fn drop_game_with_friendly(&mut self, name: &str) -> Result<(), GameDropError> { - unimplemented!() + self.tracked_games.retain(|game| match &game.friendly_name { + Some(f_name) => f_name != name, + None => false, + }); + + // TODO: Remove backup copy of game save location on disk + Ok(()) } }