Skip to content

Commit 879ed49

Browse files
authored
feat: filesystem-level error (#3217)
1 parent 7b36b7f commit 879ed49

File tree

29 files changed

+265
-81
lines changed

29 files changed

+265
-81
lines changed

Cargo.lock

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

yazi-actor/src/lives/folder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl UserData for Folder {
5656
fn add_fields<F: UserDataFields<Self>>(fields: &mut F) {
5757
cached_field!(fields, cwd, |_, me| Ok(Url::new(me.url.to_owned())));
5858
cached_field!(fields, files, |_, me| Files::make(0..me.files.len(), me, &me.tab));
59-
cached_field!(fields, stage, |_, me| Ok(FolderStage::new(me.stage)));
59+
cached_field!(fields, stage, |_, me| Ok(FolderStage::new(me.stage.clone())));
6060
cached_field!(fields, window, |_, me| Files::make(me.window.clone(), me, &me.tab));
6161

6262
fields.add_field_method_get("offset", |_, me| Ok(me.offset));

yazi-actor/src/mgr/refresh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl Refresh {
4646

4747
match Files::from_dir_bulk(&cwd).await {
4848
Ok(files) => FilesOp::Full(cwd, files, cha).emit(),
49-
Err(e) => FilesOp::issue_error(&cwd, e.kind()).await,
49+
Err(e) => FilesOp::issue_error(&cwd, e).await,
5050
}
5151
}
5252

yazi-binding/src/error.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const EXPECTED: &str = "expected a Error";
77

88
pub enum Error {
99
Io(std::io::Error),
10-
IoKind(std::io::ErrorKind),
10+
Fs(yazi_fs::error::Error),
1111
Serde(serde_json::Error),
1212
Custom(SStr),
1313
}
@@ -24,7 +24,7 @@ impl Error {
2424
pub fn into_string(self) -> SStr {
2525
match self {
2626
Self::Io(e) => Cow::Owned(e.to_string()),
27-
Self::IoKind(e) => Cow::Owned(e.to_string()),
27+
Self::Fs(e) => Cow::Owned(e.to_string()),
2828
Self::Serde(e) => Cow::Owned(e.to_string()),
2929
Self::Custom(s) => s,
3030
}
@@ -35,7 +35,7 @@ impl Display for Error {
3535
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3636
match self {
3737
Self::Io(e) => write!(f, "{e}"),
38-
Self::IoKind(e) => write!(f, "{e}"),
38+
Self::Fs(e) => write!(f, "{e}"),
3939
Self::Serde(e) => write!(f, "{e}"),
4040
Self::Custom(s) => write!(f, "{s}"),
4141
}
@@ -56,6 +56,7 @@ impl UserData for Error {
5656
fields.add_field_method_get("code", |_, me| {
5757
Ok(match me {
5858
Self::Io(e) => e.raw_os_error(),
59+
Self::Fs(e) => e.raw_os_error(),
5960
_ => None,
6061
})
6162
});
@@ -64,7 +65,7 @@ impl UserData for Error {
6465
fn add_methods<M: UserDataMethods<Self>>(methods: &mut M) {
6566
methods.add_meta_method(MetaMethod::ToString, |lua, me, ()| {
6667
Ok(match me {
67-
Self::Io(_) | Self::IoKind(_) | Self::Serde(_) => lua.create_string(me.to_string()),
68+
Self::Io(_) | Self::Fs(_) | Self::Serde(_) => lua.create_string(me.to_string()),
6869
Self::Custom(s) => lua.create_string(s.as_ref()),
6970
})
7071
});

yazi-binding/src/stage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ impl UserData for FolderStage {
1111
methods.add_meta_method(MetaMethod::Call, |lua, me, ()| {
1212
use yazi_fs::FolderStage::*;
1313

14-
match me.0 {
14+
match &me.0 {
1515
Loading => false.into_lua_multi(lua),
1616
Loaded => true.into_lua_multi(lua),
17-
Failed(kind) => (true, crate::Error::IoKind(kind)).into_lua_multi(lua),
17+
Failed(e) => (true, crate::Error::Fs(e.clone())).into_lua_multi(lua),
1818
}
1919
});
2020
}

yazi-config/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ indexmap = { workspace = true }
2626
ratatui = { workspace = true }
2727
regex = { workspace = true }
2828
serde = { workspace = true }
29+
tokio = { workspace = true }
2930
toml = { workspace = true }
3031
tracing = { workspace = true }
3132

yazi-config/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(clippy::module_inception)]
22

3-
yazi_macro::mod_pub!(keymap mgr open opener plugin popup preview tasks theme which);
3+
yazi_macro::mod_pub!(keymap mgr open opener plugin popup preview tasks theme which vfs);
44

55
yazi_macro::mod_flat!(color icon layout pattern platform preset priority style yazi);
66

yazi-config/src/preview/preview.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ impl Preview {
5656
bail!("[preview].cache_dir must be a path within local filesystem.");
5757
};
5858

59-
std::fs::create_dir_all(&self.cache_dir).context("Failed to create cache directory")?;
59+
std::fs::create_dir_all(&self.cache_dir)
60+
.context(format!("Failed to create cache directory: {}", self.cache_dir.display()))?;
6061

6162
Ok(self)
6263
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)