mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 08:12:44 +10:00
* feat: add new template options, asahi support, and refactoring * feat: install dir scanning, validation fixes, progress fixes, download manager refactor This kind of ballooned out of scope, but I implemented some much needed fixes for the download manager. First off, I cleanup the Downloadable trait, there was some duplication of function. Second, I refactored the "validate" into the GameDownloadAgent, which calls a 'validate_chunk_logic' yada, same structure as downloading. Third, I fixed the progress and validation issues. Fourth, I added game scanning * feat: out of box support for Asahi Linux * fix: clippy * fix: don't break database
47 lines
1.1 KiB
Rust
47 lines
1.1 KiB
Rust
use std::sync::{
|
|
atomic::{AtomicBool, Ordering},
|
|
Arc,
|
|
};
|
|
|
|
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
|
pub enum DownloadThreadControlFlag {
|
|
Stop,
|
|
Go,
|
|
}
|
|
/// Go => true
|
|
/// Stop => false
|
|
impl From<DownloadThreadControlFlag> for bool {
|
|
fn from(value: DownloadThreadControlFlag) -> Self {
|
|
match value {
|
|
DownloadThreadControlFlag::Go => true,
|
|
DownloadThreadControlFlag::Stop => false,
|
|
}
|
|
}
|
|
}
|
|
/// true => Go
|
|
/// false => Stop
|
|
impl From<bool> for DownloadThreadControlFlag {
|
|
fn from(value: bool) -> Self {
|
|
if value { DownloadThreadControlFlag::Go } else { DownloadThreadControlFlag::Stop }
|
|
}
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct DownloadThreadControl {
|
|
inner: Arc<AtomicBool>,
|
|
}
|
|
|
|
impl DownloadThreadControl {
|
|
pub fn new(flag: DownloadThreadControlFlag) -> Self {
|
|
Self {
|
|
inner: Arc::new(AtomicBool::new(flag.into())),
|
|
}
|
|
}
|
|
pub fn get(&self) -> DownloadThreadControlFlag {
|
|
self.inner.load(Ordering::Acquire).into()
|
|
}
|
|
pub fn set(&self, flag: DownloadThreadControlFlag) {
|
|
self.inner.store(flag.into(), Ordering::Release);
|
|
}
|
|
}
|