Skip to content

Commit 157156b

Browse files
authored
fix: a race condition in concurrent directory loading on a slow device (#3271)
1 parent b16c489 commit 157156b

File tree

8 files changed

+107
-64
lines changed

8 files changed

+107
-64
lines changed

.github/workflows/validate-form.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
- uses: actions/checkout@v5
1616

1717
- name: Setup Node.js
18-
uses: actions/setup-node@v5
18+
uses: actions/setup-node@v6
1919
with:
20-
node-js: 20
20+
node-version: 20
2121

2222
- name: Install Dependencies
2323
run: |

Cargo.lock

Lines changed: 40 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ lto = false
2323
ansi-to-tui = "7.0.0"
2424
anyhow = "1.0.100"
2525
base64 = "0.22.1"
26-
bitflags = { version = "2.9.4", features = [ "serde" ] }
27-
clap = { version = "4.5.49", features = [ "derive" ] }
26+
bitflags = { version = "2.10.0", features = [ "serde" ] }
27+
clap = { version = "4.5.50", features = [ "derive" ] }
2828
core-foundation-sys = "0.8.7"
2929
crossterm = { version = "0.29.0", features = [ "event-stream" ] }
3030
dirs = "6.0.0"

yazi-actor/src/context.rs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ use yazi_fs::File;
66
use yazi_shared::{Id, Source, event::Cmd, url::UrlBuf};
77

88
pub struct Ctx<'a> {
9-
pub core: &'a mut Core,
10-
pub tab: usize,
11-
pub level: usize,
12-
pub source: Source,
9+
pub core: &'a mut Core,
10+
pub tab: usize,
11+
pub level: usize,
12+
pub source: Source,
13+
#[cfg(debug_assertions)]
14+
pub backtrace: Vec<&'static str>,
1315
}
1416

1517
impl Deref for Ctx<'_> {
@@ -36,19 +38,40 @@ impl<'a> Ctx<'a> {
3638
core.mgr.tabs.cursor
3739
};
3840

39-
Ok(Self { core, tab, level: 0, source: cmd.source })
41+
Ok(Self {
42+
core,
43+
tab,
44+
level: 0,
45+
source: cmd.source,
46+
#[cfg(debug_assertions)]
47+
backtrace: vec![],
48+
})
4049
}
4150

4251
#[inline]
4352
pub fn renew<'b>(cx: &'a mut Ctx<'b>) -> Self {
4453
let tab = cx.core.mgr.tabs.cursor;
45-
Self { core: cx.core, tab, level: cx.level, source: cx.source }
54+
Self {
55+
core: cx.core,
56+
tab,
57+
level: cx.level,
58+
source: cx.source,
59+
#[cfg(debug_assertions)]
60+
backtrace: vec![],
61+
}
4662
}
4763

4864
#[inline]
4965
pub fn active(core: &'a mut Core) -> Self {
5066
let tab = core.mgr.tabs.cursor;
51-
Self { core, tab, level: 0, source: Source::Unknown }
67+
Self {
68+
core,
69+
tab,
70+
level: 0,
71+
source: Source::Unknown,
72+
#[cfg(debug_assertions)]
73+
backtrace: vec![],
74+
}
5275
}
5376
}
5477

yazi-actor/src/mgr/peek.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ impl Actor for Peek {
3030
if !cx.tab().preview.same_file(&hovered, &mime) {
3131
cx.tab_mut().preview.reset();
3232
}
33+
if !cx.tab().preview.same_folder(&hovered.url) {
34+
cx.tab_mut().preview.folder_lock = None;
35+
}
3336

3437
if matches!(opt.only_if, Some(u) if u != hovered.url) {
3538
succ!();
@@ -45,7 +48,7 @@ impl Actor for Peek {
4548
}
4649

4750
if hovered.is_dir() {
48-
cx.tab_mut().preview.go_folder(hovered, folder.map(|(_, cha)| cha), opt.force);
51+
cx.tab_mut().preview.go_folder(hovered, folder.map(|(_, cha)| cha), mime, opt.force);
4952
} else {
5053
cx.tab_mut().preview.go(hovered, mime, opt.force);
5154
}

0 commit comments

Comments
 (0)