mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-15 09:11:28 +10:00
feat: move to native_model to allow for database upgrades
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
use std::sync::Mutex;
|
||||
|
||||
use crate::{download_manager::downloadable_metadata::DownloadableMetadata, AppState};
|
||||
use crate::{database::models::data::DownloadableMetadata, AppState};
|
||||
|
||||
#[tauri::command]
|
||||
pub fn pause_downloads(state: tauri::State<'_, Mutex<AppState>>) {
|
||||
|
||||
@ -12,11 +12,10 @@ use std::{
|
||||
use log::{debug, info};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::error::application_download_error::ApplicationDownloadError;
|
||||
use crate::{database::models::data::DownloadableMetadata, error::application_download_error::ApplicationDownloadError};
|
||||
|
||||
use super::{
|
||||
download_manager_builder::{CurrentProgressObject, DownloadAgent},
|
||||
downloadable_metadata::DownloadableMetadata,
|
||||
queue::Queue,
|
||||
};
|
||||
|
||||
@ -167,10 +166,7 @@ impl DownloadManager {
|
||||
self.command_sender
|
||||
.send(DownloadManagerSignal::UpdateUIQueue)
|
||||
.unwrap();
|
||||
self.command_sender
|
||||
.send(DownloadManagerSignal::Go)
|
||||
.unwrap();
|
||||
|
||||
self.command_sender.send(DownloadManagerSignal::Go).unwrap();
|
||||
}
|
||||
pub fn pause_downloads(&self) {
|
||||
self.command_sender
|
||||
|
||||
@ -11,15 +11,13 @@ use log::{debug, error, info, warn};
|
||||
use tauri::{AppHandle, Emitter};
|
||||
|
||||
use crate::{
|
||||
error::application_download_error::ApplicationDownloadError,
|
||||
games::library::{QueueUpdateEvent, QueueUpdateEventQueueData, StatsUpdateEvent},
|
||||
database::models::data::DownloadableMetadata, error::application_download_error::ApplicationDownloadError, games::library::{QueueUpdateEvent, QueueUpdateEventQueueData, StatsUpdateEvent}
|
||||
};
|
||||
|
||||
use super::{
|
||||
download_manager::{DownloadManager, DownloadManagerSignal, DownloadManagerStatus},
|
||||
download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag},
|
||||
downloadable::Downloadable,
|
||||
downloadable_metadata::DownloadableMetadata,
|
||||
progress_object::ProgressObject,
|
||||
queue::Queue,
|
||||
};
|
||||
@ -209,7 +207,9 @@ impl DownloadManagerBuilder {
|
||||
}
|
||||
|
||||
if self.current_download_agent.is_some() {
|
||||
if self.download_queue.read().front().unwrap() == &self.current_download_agent.as_ref().unwrap().metadata() {
|
||||
if self.download_queue.read().front().unwrap()
|
||||
== &self.current_download_agent.as_ref().unwrap().metadata()
|
||||
{
|
||||
debug!(
|
||||
"Current download agent: {:?}",
|
||||
self.current_download_agent.as_ref().unwrap().metadata()
|
||||
|
||||
@ -2,11 +2,11 @@ use std::sync::Arc;
|
||||
|
||||
use tauri::AppHandle;
|
||||
|
||||
use crate::error::application_download_error::ApplicationDownloadError;
|
||||
use crate::{database::models::data::DownloadableMetadata, error::application_download_error::ApplicationDownloadError};
|
||||
|
||||
use super::{
|
||||
download_manager::DownloadStatus, download_thread_control_flag::DownloadThreadControl,
|
||||
downloadable_metadata::DownloadableMetadata, progress_object::ProgressObject,
|
||||
progress_object::ProgressObject,
|
||||
};
|
||||
|
||||
pub trait Downloadable: Send + Sync {
|
||||
|
||||
@ -1,26 +1 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Clone, Copy)]
|
||||
pub enum DownloadType {
|
||||
Game,
|
||||
Tool,
|
||||
DLC,
|
||||
Mod,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DownloadableMetadata {
|
||||
pub id: String,
|
||||
pub version: Option<String>,
|
||||
pub download_type: DownloadType,
|
||||
}
|
||||
impl DownloadableMetadata {
|
||||
pub fn new(id: String, version: Option<String>, download_type: DownloadType) -> Self {
|
||||
Self {
|
||||
id,
|
||||
version,
|
||||
download_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -3,7 +3,7 @@ use std::{
|
||||
sync::{Arc, Mutex, MutexGuard},
|
||||
};
|
||||
|
||||
use super::downloadable_metadata::DownloadableMetadata;
|
||||
use crate::database::models::data::DownloadableMetadata;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Queue {
|
||||
|
||||
Reference in New Issue
Block a user