chore(download manager): Renamed most instances of "game" outside of actual game downloads

Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
quexeky
2024-12-30 21:29:14 +11:00
parent b4d70a35b3
commit 881fcc6abe
10 changed files with 183 additions and 178 deletions

View File

@ -23,7 +23,7 @@ pub struct DatabaseAuth {
// Strings are version names for a particular game
#[derive(Serialize, Clone, Deserialize)]
#[serde(tag = "type")]
pub enum GameStatus {
pub enum ApplicationStatus {
Remote {},
SetupRequired {
version_name: String,
@ -37,7 +37,7 @@ pub enum GameStatus {
// Stuff that shouldn't be synced to disk
#[derive(Clone, Serialize)]
pub enum GameTransientStatus {
pub enum ApplicationTransientStatus {
Downloading { version_name: String },
Uninstalling {},
Updating { version_name: String },
@ -46,7 +46,7 @@ pub enum GameTransientStatus {
#[derive(Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct GameVersion {
pub struct ApplicationVersion {
pub version_index: usize,
pub version_name: String,
pub launch_command: String,
@ -55,14 +55,15 @@ pub struct GameVersion {
}
#[derive(Serialize, Clone, Deserialize)]
pub struct DatabaseGames {
#[serde(rename_all = "camelCase")]
pub struct DatabaseApplications {
pub install_dirs: Vec<String>,
// Guaranteed to exist if the game also exists in the app state map
pub statuses: HashMap<String, GameStatus>,
pub versions: HashMap<String, HashMap<String, GameVersion>>,
pub statuses: HashMap<String, ApplicationStatus>,
pub versions: HashMap<String, HashMap<String, ApplicationVersion>>,
#[serde(skip)]
pub transient_statuses: HashMap<String, GameTransientStatus>,
pub transient_statuses: HashMap<String, ApplicationTransientStatus>,
}
#[derive(Serialize, Deserialize, Clone)]
@ -86,7 +87,7 @@ pub struct Database {
pub settings: Settings,
pub auth: Option<DatabaseAuth>,
pub base_url: String,
pub games: DatabaseGames,
pub applications: DatabaseApplications,
}
pub static DATA_ROOT_DIR: LazyLock<Mutex<PathBuf>> =
LazyLock::new(|| Mutex::new(BaseDirs::new().unwrap().data_dir().join("drop")));
@ -136,7 +137,7 @@ impl DatabaseImpls for DatabaseInterface {
settings: Settings::default(),
auth: None,
base_url: "".to_string(),
games: DatabaseGames {
applications: DatabaseApplications {
install_dirs: vec![games_base_dir.to_str().unwrap().to_string()],
statuses: HashMap::new(),
transient_statuses: HashMap::new(),
@ -187,10 +188,10 @@ pub fn add_download_dir(new_dir: String) -> Result<(), String> {
// Add it to the dictionary
let mut lock = DB.borrow_data_mut().unwrap();
if lock.games.install_dirs.contains(&new_dir) {
if lock.applications.install_dirs.contains(&new_dir) {
return Err("Download directory already used".to_string());
}
lock.games.install_dirs.push(new_dir);
lock.applications.install_dirs.push(new_dir);
drop(lock);
DB.save().unwrap();
@ -200,7 +201,7 @@ pub fn add_download_dir(new_dir: String) -> Result<(), String> {
#[tauri::command]
pub fn delete_download_dir(index: usize) -> Result<(), String> {
let mut lock = DB.borrow_data_mut().unwrap();
lock.games.install_dirs.remove(index);
lock.applications.install_dirs.remove(index);
drop(lock);
DB.save().unwrap();
@ -212,7 +213,7 @@ pub fn delete_download_dir(index: usize) -> Result<(), String> {
#[tauri::command]
pub fn fetch_download_dir_stats() -> Result<Vec<String>, String> {
let lock = DB.borrow_data().unwrap();
let directories = lock.games.install_dirs.clone();
let directories = lock.applications.install_dirs.clone();
drop(lock);
Ok(directories)