mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-14 16:51:18 +10:00
chore(downloads): Added time debugging and fixed logging formatting
This commit is contained in:
@ -6,12 +6,14 @@ use crate::remote::RemoteAccessError;
|
||||
use crate::DB;
|
||||
use log::{debug, error, info};
|
||||
use rayon::ThreadPoolBuilder;
|
||||
use core::time;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::fs::{create_dir_all, File};
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Instant;
|
||||
use urlencoding::encode;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
@ -99,8 +101,10 @@ impl GameDownloadAgent {
|
||||
pub fn download(&self) -> Result<(), GameDownloadError> {
|
||||
self.setup_download()?;
|
||||
self.set_progress_object_params();
|
||||
let timer = Instant::now();
|
||||
self.run().map_err(|_| GameDownloadError::DownloadError)?;
|
||||
|
||||
info!("{} took {}ms to download", self.id, timer.elapsed().as_millis());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@ -201,6 +201,7 @@ impl DownloadManagerBuilder {
|
||||
|
||||
fn manage_stop_signal(&mut self) {
|
||||
info!("Got signal 'Stop'");
|
||||
self.set_status(DownloadManagerStatus::Paused);
|
||||
if let Some(active_control_flag) = self.active_control_flag.clone() {
|
||||
active_control_flag.set(DownloadThreadControlFlag::Stop);
|
||||
}
|
||||
@ -327,6 +328,7 @@ impl DownloadManagerBuilder {
|
||||
self.sender.send(DownloadManagerSignal::Update).unwrap();
|
||||
}
|
||||
fn manage_cancel_signal(&mut self) {
|
||||
self.set_status(DownloadManagerStatus::Paused);
|
||||
if let Some(current_flag) = &self.active_control_flag {
|
||||
current_flag.set(DownloadThreadControlFlag::Stop);
|
||||
}
|
||||
|
||||
@ -76,12 +76,12 @@ fn fetch_state(state: tauri::State<'_, Mutex<AppState>>) -> Result<AppState, Str
|
||||
|
||||
fn setup(handle: AppHandle) -> AppState {
|
||||
let logfile = FileAppender::builder()
|
||||
.encoder(Box::new(PatternEncoder::new("{t}|{l}|{f} - {m}{n}")))
|
||||
.encoder(Box::new(PatternEncoder::new("{d} | {l} | {f} - {m}{n}")))
|
||||
.build(DATA_ROOT_DIR.lock().unwrap().join("./drop.log"))
|
||||
.unwrap();
|
||||
|
||||
let console = ConsoleAppender::builder()
|
||||
.encoder(Box::new(PatternEncoder::new("{t}|{l}|{f} - {m}{n}\n")))
|
||||
.encoder(Box::new(PatternEncoder::new("{d} | {l} | {f} - {m}{n}\n")))
|
||||
.build();
|
||||
|
||||
let config = Config::builder()
|
||||
|
||||
Reference in New Issue
Block a user