mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 00:02:41 +10:00
feat(library): Added option to change root directory
Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
@ -8,6 +8,7 @@
|
|||||||
<input placeholder="GAME ID" v-model="gameId" />
|
<input placeholder="GAME ID" v-model="gameId" />
|
||||||
<input placeholder="VERSION NAME" v-model="versionName" />
|
<input placeholder="VERSION NAME" v-model="versionName" />
|
||||||
<input placeholder="STATUS" v-model="status" />
|
<input placeholder="STATUS" v-model="status" />
|
||||||
|
<input placeholder="NEW ROOT DIR" v-model="newRootDir" />
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="w-full rounded-md p-4 bg-blue-600 text-white"
|
class="w-full rounded-md p-4 bg-blue-600 text-white"
|
||||||
@ -36,6 +37,12 @@
|
|||||||
>
|
>
|
||||||
Set game download progress
|
Set game download progress
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
class="w-full rounded-md p-4 bg-blue-600 text-white"
|
||||||
|
@click="changeRootDirectoryWrapper"
|
||||||
|
>
|
||||||
|
Change root download location
|
||||||
|
</button>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -44,6 +51,8 @@ import { invoke } from "@tauri-apps/api/core";
|
|||||||
const gameId = ref("");
|
const gameId = ref("");
|
||||||
const versionName = ref("");
|
const versionName = ref("");
|
||||||
const status = ref("");
|
const status = ref("");
|
||||||
|
const newRootDir = ref("");
|
||||||
|
|
||||||
|
|
||||||
async function queueGame() {
|
async function queueGame() {
|
||||||
await invoke("queue_game_download", {
|
await invoke("queue_game_download", {
|
||||||
@ -63,7 +72,7 @@ function queueGameWrapper() {
|
|||||||
}
|
}
|
||||||
async function startGameDownloads() {
|
async function startGameDownloads() {
|
||||||
console.log("Downloading Games");
|
console.log("Downloading Games");
|
||||||
await invoke("start_game_downloads", { maxThreads: 4 })
|
await invoke("start_game_downloads", { maxThreads: 4 });
|
||||||
console.log("Finished downloading games");
|
console.log("Finished downloading games");
|
||||||
}
|
}
|
||||||
function startGameDownloadsWrapper() {
|
function startGameDownloadsWrapper() {
|
||||||
@ -83,7 +92,7 @@ function cancelGameDownloadWrapper() {
|
|||||||
}
|
}
|
||||||
async function getGameDownloadProgress() {
|
async function getGameDownloadProgress() {
|
||||||
console.log("Getting game download status");
|
console.log("Getting game download status");
|
||||||
await invoke("get_game_download_progress", { gameId: gameId.value })
|
await invoke("get_game_download_progress", { gameId: gameId.value });
|
||||||
}
|
}
|
||||||
function getGameDownloadProgressWrapper() {
|
function getGameDownloadProgressWrapper() {
|
||||||
getGameDownloadProgress()
|
getGameDownloadProgress()
|
||||||
@ -106,7 +115,7 @@ function getGameDownloadProgressWrapper() {
|
|||||||
|
|
||||||
async function setGameDownloadStatus(status: string) {
|
async function setGameDownloadStatus(status: string) {
|
||||||
console.log("Setting game download status");
|
console.log("Setting game download status");
|
||||||
await invoke("set_download_state", { gameId: gameId.value, status: status })
|
await invoke("set_download_state", { gameId: gameId.value, status: status });
|
||||||
}
|
}
|
||||||
function setGameDownloadStatusWrapper() {
|
function setGameDownloadStatusWrapper() {
|
||||||
console.log("Called setGameDownloadWrapper");
|
console.log("Called setGameDownloadWrapper");
|
||||||
@ -116,4 +125,15 @@ function setGameDownloadStatusWrapper() {
|
|||||||
console.log(e)
|
console.log(e)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
async function changeRootDirectory() {
|
||||||
|
console.log("Changing root directory");
|
||||||
|
await invoke("change_root_directory", { newDir: newRootDir.value });
|
||||||
|
}
|
||||||
|
function changeRootDirectoryWrapper() {
|
||||||
|
changeRootDirectory()
|
||||||
|
.then(() => {})
|
||||||
|
.catch((e) => {
|
||||||
|
console.log(e)
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -6,11 +6,12 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use directories::BaseDirs;
|
use directories::BaseDirs;
|
||||||
|
use log::info;
|
||||||
use rustbreak::{deser::Bincode, PathDatabase};
|
use rustbreak::{deser::Bincode, PathDatabase};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::DB;
|
use crate::{AppState, DB};
|
||||||
|
|
||||||
#[derive(serde::Serialize, Clone, Deserialize)]
|
#[derive(serde::Serialize, Clone, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[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();
|
let mut lock = DATA_ROOT_DIR.lock().unwrap();
|
||||||
*lock = new_dir.into();
|
*lock = new_dir.into();
|
||||||
}
|
}
|
||||||
@ -10,7 +10,7 @@ mod tests;
|
|||||||
use crate::db::DatabaseImpls;
|
use crate::db::DatabaseImpls;
|
||||||
use crate::downloads::download_agent::GameDownloadAgent;
|
use crate::downloads::download_agent::GameDownloadAgent;
|
||||||
use auth::{auth_initiate, generate_authorization_header, recieve_handshake};
|
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 downloads::download_commands::*;
|
||||||
use env_logger::Env;
|
use env_logger::Env;
|
||||||
use http::{header::*, response::Builder as ResponseBuilder};
|
use http::{header::*, response::Builder as ResponseBuilder};
|
||||||
@ -119,6 +119,7 @@ pub fn run() {
|
|||||||
// Library
|
// Library
|
||||||
fetch_library,
|
fetch_library,
|
||||||
fetch_game,
|
fetch_game,
|
||||||
|
change_root_directory,
|
||||||
// Downloads
|
// Downloads
|
||||||
queue_game_download,
|
queue_game_download,
|
||||||
start_game_downloads,
|
start_game_downloads,
|
||||||
|
|||||||
Reference in New Issue
Block a user