feat(library): Added option to change root directory

Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
quexeky
2024-11-10 13:18:28 +11:00
parent 00b7179743
commit 1aa52c0a21
3 changed files with 30 additions and 6 deletions

View File

@ -6,11 +6,12 @@ use std::{
};
use directories::BaseDirs;
use log::info;
use rustbreak::{deser::Bincode, PathDatabase};
use serde::{Deserialize, Serialize};
use url::Url;
use crate::DB;
use crate::{AppState, DB};
#[derive(serde::Serialize, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
@ -91,7 +92,9 @@ impl DatabaseImpls for DatabaseInterface {
}
}
fn change_root_directory<T: Into<PathBuf>>(new_dir: T) {
#[tauri::command]
pub fn change_root_directory(new_dir: String) {
info!("Changed root directory to {}", new_dir);
let mut lock = DATA_ROOT_DIR.lock().unwrap();
*lock = new_dir.into();
}

View File

@ -10,7 +10,7 @@ mod tests;
use crate::db::DatabaseImpls;
use crate::downloads::download_agent::GameDownloadAgent;
use auth::{auth_initiate, generate_authorization_header, recieve_handshake};
use db::{DatabaseInterface, DATA_ROOT_DIR};
use db::{change_root_directory, DatabaseInterface, DATA_ROOT_DIR};
use downloads::download_commands::*;
use env_logger::Env;
use http::{header::*, response::Builder as ResponseBuilder};
@ -119,6 +119,7 @@ pub fn run() {
// Library
fetch_library,
fetch_game,
change_root_directory,
// Downloads
queue_game_download,
start_game_downloads,