chore: clean up warnings and public api
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::utils::{self, ProjectDirError};
|
||||
use log::{debug, info, trace, warn};
|
||||
use log::debug;
|
||||
use save_sync::db::{establish_connection, query::GameSaveQuery, Database};
|
||||
use save_sync::game::{GameFile, GameSaveLocation};
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -158,13 +158,13 @@ impl Archive {
|
||||
}
|
||||
|
||||
impl Archive {
|
||||
pub fn drop_game<P: AsRef<Path>>(path: P) -> Result<Option<()>, GameDropError> {
|
||||
pub fn drop_game<P: AsRef<Path>>(path: P) -> Result<usize, GameDropError> {
|
||||
let conn = establish_connection();
|
||||
let query = GameSaveQuery::Path(path.as_ref());
|
||||
Ok(Database::drop_game_save(&conn, query)?)
|
||||
}
|
||||
|
||||
pub fn drop_game_with_friendly(name: &str) -> Result<Option<()>, GameDropError> {
|
||||
pub fn drop_game_with_friendly(name: &str) -> Result<usize, GameDropError> {
|
||||
let conn = establish_connection();
|
||||
let query = GameSaveQuery::FriendlyName(name);
|
||||
Ok(Database::drop_game_save(&conn, query)?)
|
||||
|
||||
@@ -2,9 +2,7 @@ use clap::{crate_authors, crate_description, crate_version, ArgMatches};
|
||||
use clap::{App, Arg, SubCommand};
|
||||
use client::archive::Archive;
|
||||
use dotenv::dotenv;
|
||||
use log::{debug, info};
|
||||
use save_sync::db::{establish_connection, Database};
|
||||
use std::path::Path;
|
||||
use log::info;
|
||||
|
||||
fn main() {
|
||||
dotenv().ok();
|
||||
@@ -116,42 +114,48 @@ fn tracked_save_info(matches: &ArgMatches) {
|
||||
Archive::get_game(path_str).expect("Failed to get game save info from Archive")
|
||||
};
|
||||
|
||||
let game = maybe_game.expect("No tracked game save found");
|
||||
match maybe_game {
|
||||
Some(game) => {
|
||||
if let Some(name) = game.friendly_name {
|
||||
println!("Friendly Name: {}", name);
|
||||
} else {
|
||||
println!("Friendly Name: None");
|
||||
}
|
||||
|
||||
if let Some(name) = game.friendly_name {
|
||||
println!("Friendly Name: {}", name);
|
||||
} else {
|
||||
println!("Friendly Name: None");
|
||||
}
|
||||
println!("Original Path: {:?}", game.original_path);
|
||||
println!("UUID: {:?}", game.uuid);
|
||||
println!("---\nFiles:");
|
||||
|
||||
println!("Original Path: {:?}", game.original_path);
|
||||
println!("UUID: {:?}", game.uuid);
|
||||
println!("---\nFiles:");
|
||||
|
||||
for file in game.files {
|
||||
println!("Path: {:?}", file.original_path);
|
||||
println!("Hash: {}", file.hash);
|
||||
println!();
|
||||
for file in game.files {
|
||||
println!("Path: {:?}", file.original_path);
|
||||
println!("Hash: {}", file.hash);
|
||||
println!();
|
||||
}
|
||||
}
|
||||
None => println!("No tracked game save was found."),
|
||||
}
|
||||
}
|
||||
|
||||
fn list_tracked_saves(_matches: &ArgMatches) {
|
||||
let games = Archive::get_all_games()
|
||||
.expect("Failed to get all Games from the Archive")
|
||||
.expect("There are no tracked Games");
|
||||
let maybe_games = Archive::get_all_games().expect("Failed to get all Games from the Archive");
|
||||
|
||||
for game in games {
|
||||
if let Some(name) = game.friendly_name {
|
||||
print!("[{}] ", name);
|
||||
match maybe_games {
|
||||
Some(games) => {
|
||||
for game in games {
|
||||
if let Some(name) = game.friendly_name {
|
||||
print!("[{}] ", name);
|
||||
}
|
||||
println!("{:?}", game.original_path);
|
||||
println!("UUID: {:?}", game.uuid);
|
||||
println!("---");
|
||||
}
|
||||
}
|
||||
println!("{:?}", game.original_path);
|
||||
println!("UUID: {:?}", game.uuid);
|
||||
println!("---");
|
||||
None => println!("There are no tracked games"),
|
||||
}
|
||||
}
|
||||
|
||||
fn drop_save(matches: &ArgMatches) {
|
||||
let maybe_compromised = if let Some(name) = matches.value_of("friendly") {
|
||||
let items_deleted = if let Some(name) = matches.value_of("friendly") {
|
||||
Archive::drop_game_with_friendly(name).expect("Archive failed to delete from database")
|
||||
} else {
|
||||
let path_str = matches
|
||||
@@ -161,8 +165,9 @@ fn drop_save(matches: &ArgMatches) {
|
||||
Archive::drop_game(path_str).expect("Archive failed to delete from database")
|
||||
};
|
||||
|
||||
match maybe_compromised {
|
||||
Some(()) => println!("Game successfully dropped from the list"),
|
||||
None => panic!("Database Invariant broken. Database is corrupted."),
|
||||
match items_deleted {
|
||||
0 => println!("Save Sync can't drop what was never tracked to begin with"),
|
||||
1 => println!("Save Sync successfully dropped the game from the list of tracked games"),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,6 @@
|
||||
use directories::ProjectDirs;
|
||||
use std::path::Path;
|
||||
use thiserror::Error;
|
||||
|
||||
pub fn calc_file_hash(path: &Path) -> Option<u64> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn archive_directory(src: &Path, dst: &Path) -> Result<(), Box<dyn std::error::Error>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn archive_file(src: &Path, dst: &Path) -> Result<(), Box<dyn std::error::Error>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn unarchive_directory(src: &Path, dst: &Path) -> Result<(), Box<dyn std::error::Error>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn unarchive_file(src: &Path, dst: &Path) -> Result<(), Box<dyn std::error::Error>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn get_project_dirs() -> Result<ProjectDirs, ProjectDirError> {
|
||||
ProjectDirs::from("dev", "musuka", "save-sync").ok_or(ProjectDirError::HomeNotSet)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user