mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-18 22:31:35 +03:00
fix: the number of left tasks cannot be updated
This commit is contained in:
parent
b438501d2d
commit
d798874492
@ -197,14 +197,14 @@ impl Scheduler {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let running = self.running.clone();
|
let running = self.running.clone();
|
||||||
let mut last = 100;
|
let mut last = (100, 0);
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
loop {
|
loop {
|
||||||
sleep(Duration::from_secs(1)).await;
|
sleep(Duration::from_secs(1)).await;
|
||||||
if running.read().is_empty() {
|
if running.read().is_empty() {
|
||||||
if last != 100 {
|
if last != (100, 0) {
|
||||||
last = 100;
|
last = (100, 0);
|
||||||
emit!(Progress(100, 0));
|
emit!(Progress(last.0, last.1));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -218,19 +218,19 @@ impl Scheduler {
|
|||||||
progress = (progress.0 + task.done, progress.1 + task.todo);
|
progress = (progress.0 + task.done, progress.1 + task.todo);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut new = match progress.1 {
|
let mut percent = match progress.1 {
|
||||||
0 => 100u8,
|
0 => 100u8,
|
||||||
_ => 100.min(progress.0 * 100 / progress.1) as u8,
|
_ => 100.min(progress.0 * 100 / progress.1) as u8,
|
||||||
};
|
};
|
||||||
|
|
||||||
if tasks != 0 {
|
if tasks != 0 {
|
||||||
new = new.min(99);
|
percent = percent.min(99);
|
||||||
left = left.max(1);
|
left = left.max(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if new != last {
|
if last != (percent, left) {
|
||||||
last = new;
|
last = (percent, left);
|
||||||
emit!(Progress(new, left));
|
emit!(Progress(last.0, last.1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -212,15 +212,6 @@ impl Tasks {
|
|||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_progress(&mut self, percent: u8, left: u32) -> bool {
|
|
||||||
if self.progress.0 == percent {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.progress = (percent, left);
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tasks {
|
impl Tasks {
|
||||||
|
@ -132,7 +132,7 @@ impl App {
|
|||||||
self.cx.tasks.file_open(targets);
|
self.cx.tasks.file_open(targets);
|
||||||
}
|
}
|
||||||
Event::Progress(percent, left) => {
|
Event::Progress(percent, left) => {
|
||||||
self.cx.tasks.update_progress(percent, left);
|
self.cx.tasks.progress = (percent, left);
|
||||||
emit!(Render);
|
emit!(Render);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user