mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-08-24 07:12:04 +10:00
Game updates (#187)
* refactor: split umu launcher * feat: latest version picker + fixes * feat: frontend latest changes * feat: game update detection w/ setting * feat: fixes and refactor for game update * fix: windows ui * fix: deps * feat: update modifications * feat: missing ui and lock update * fix: create install dir on init * fix: clippy * fix: clippy x2 * feat: add configuration option to toggle updates * feat: uninstall dropdown on partiallyinstalled
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
|
||||
use database::{
|
||||
DownloadType, DownloadableMetadata, GameDownloadStatus, borrow_db_checked, platform::Platform,
|
||||
DownloadType, DownloadableMetadata, GameDownloadStatus, borrow_db_checked,
|
||||
models::data::{InstalledGameType, UserConfiguration},
|
||||
platform::Platform,
|
||||
};
|
||||
use download_manager::{
|
||||
DOWNLOAD_MANAGER, downloadable::Downloadable, error::ApplicationDownloadError,
|
||||
@@ -14,20 +16,8 @@ pub async fn download_game(
|
||||
version_id: String,
|
||||
target_platform: Platform,
|
||||
install_dir: usize,
|
||||
enable_updates: bool,
|
||||
) -> Result<(), ApplicationDownloadError> {
|
||||
{
|
||||
let db = borrow_db_checked();
|
||||
let status = db
|
||||
.applications
|
||||
.game_statuses
|
||||
.get(&game_id)
|
||||
.unwrap_or(&GameDownloadStatus::Remote {});
|
||||
|
||||
if matches!(status, GameDownloadStatus::Installed { .. }) {
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
let sender = { DOWNLOAD_MANAGER.get_sender().clone() };
|
||||
|
||||
let meta = DownloadableMetadata {
|
||||
@@ -37,11 +27,32 @@ pub async fn download_game(
|
||||
download_type: DownloadType::Game,
|
||||
};
|
||||
|
||||
let game_download_agent = GameDownloadAgent::new_from_index(
|
||||
{
|
||||
let db = borrow_db_checked();
|
||||
let status = db.applications.transient_statuses.get(&meta);
|
||||
|
||||
if status.is_some() {
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
let configuration = UserConfiguration {
|
||||
enable_updates,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let base_dir = {
|
||||
let db_lock = borrow_db_checked();
|
||||
|
||||
db_lock.applications.install_dirs[install_dir].clone()
|
||||
};
|
||||
|
||||
let game_download_agent = GameDownloadAgent::new(
|
||||
meta,
|
||||
install_dir,
|
||||
base_dir,
|
||||
sender,
|
||||
DOWNLOAD_MANAGER.clone_depot_manager(),
|
||||
configuration,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -58,7 +69,7 @@ pub async fn download_game(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn resume_download(game_id: String) -> Result<(), ApplicationDownloadError> {
|
||||
let (meta, install_dir) = {
|
||||
let (meta, (install_dir, configuration)) = {
|
||||
let db_lock = borrow_db_checked();
|
||||
let status = db_lock
|
||||
.applications
|
||||
@@ -75,12 +86,12 @@ pub async fn resume_download(game_id: String) -> Result<(), ApplicationDownloadE
|
||||
.clone();
|
||||
|
||||
let install_dir = match status {
|
||||
GameDownloadStatus::Remote {} => Err(ApplicationDownloadError::InvalidCommand),
|
||||
GameDownloadStatus::SetupRequired { .. } => {
|
||||
Err(ApplicationDownloadError::InvalidCommand)
|
||||
}
|
||||
GameDownloadStatus::Installed { .. } => Err(ApplicationDownloadError::InvalidCommand),
|
||||
GameDownloadStatus::PartiallyInstalled { install_dir, .. } => Ok(install_dir),
|
||||
GameDownloadStatus::Installed {
|
||||
install_type: InstalledGameType::PartiallyInstalled { configuration },
|
||||
install_dir,
|
||||
..
|
||||
} => Ok((install_dir, configuration)),
|
||||
_ => Err(ApplicationDownloadError::InvalidCommand),
|
||||
}?;
|
||||
(meta, install_dir)
|
||||
};
|
||||
@@ -98,6 +109,7 @@ pub async fn resume_download(game_id: String) -> Result<(), ApplicationDownloadE
|
||||
install_dir.to_path_buf(),
|
||||
sender,
|
||||
DOWNLOAD_MANAGER.clone_depot_manager(),
|
||||
configuration,
|
||||
)
|
||||
.await?,
|
||||
) as Box<dyn Downloadable + Send + Sync>);
|
||||
|
||||
Reference in New Issue
Block a user