mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-15 01:01:25 +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 crate::DB;
|
||||||
use log::{debug, error, info};
|
use log::{debug, error, info};
|
||||||
use rayon::ThreadPoolBuilder;
|
use rayon::ThreadPoolBuilder;
|
||||||
|
use core::time;
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
use std::fs::{create_dir_all, File};
|
use std::fs::{create_dir_all, File};
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
use std::time::Instant;
|
||||||
use urlencoding::encode;
|
use urlencoding::encode;
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@ -99,8 +101,10 @@ impl GameDownloadAgent {
|
|||||||
pub fn download(&self) -> Result<(), GameDownloadError> {
|
pub fn download(&self) -> Result<(), GameDownloadError> {
|
||||||
self.setup_download()?;
|
self.setup_download()?;
|
||||||
self.set_progress_object_params();
|
self.set_progress_object_params();
|
||||||
|
let timer = Instant::now();
|
||||||
self.run().map_err(|_| GameDownloadError::DownloadError)?;
|
self.run().map_err(|_| GameDownloadError::DownloadError)?;
|
||||||
|
|
||||||
|
info!("{} took {}ms to download", self.id, timer.elapsed().as_millis());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -201,6 +201,7 @@ impl DownloadManagerBuilder {
|
|||||||
|
|
||||||
fn manage_stop_signal(&mut self) {
|
fn manage_stop_signal(&mut self) {
|
||||||
info!("Got signal 'Stop'");
|
info!("Got signal 'Stop'");
|
||||||
|
self.set_status(DownloadManagerStatus::Paused);
|
||||||
if let Some(active_control_flag) = self.active_control_flag.clone() {
|
if let Some(active_control_flag) = self.active_control_flag.clone() {
|
||||||
active_control_flag.set(DownloadThreadControlFlag::Stop);
|
active_control_flag.set(DownloadThreadControlFlag::Stop);
|
||||||
}
|
}
|
||||||
@ -327,6 +328,7 @@ impl DownloadManagerBuilder {
|
|||||||
self.sender.send(DownloadManagerSignal::Update).unwrap();
|
self.sender.send(DownloadManagerSignal::Update).unwrap();
|
||||||
}
|
}
|
||||||
fn manage_cancel_signal(&mut self) {
|
fn manage_cancel_signal(&mut self) {
|
||||||
|
self.set_status(DownloadManagerStatus::Paused);
|
||||||
if let Some(current_flag) = &self.active_control_flag {
|
if let Some(current_flag) = &self.active_control_flag {
|
||||||
current_flag.set(DownloadThreadControlFlag::Stop);
|
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 {
|
fn setup(handle: AppHandle) -> AppState {
|
||||||
let logfile = FileAppender::builder()
|
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"))
|
.build(DATA_ROOT_DIR.lock().unwrap().join("./drop.log"))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let console = ConsoleAppender::builder()
|
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();
|
.build();
|
||||||
|
|
||||||
let config = Config::builder()
|
let config = Config::builder()
|
||||||
|
|||||||
Reference in New Issue
Block a user