diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a18e6849..624175c0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,6 +22,13 @@ jobs: installers-regex: 'yazi-(x86_64|aarch64)-pc-windows-msvc\.zip$' token: ${{ secrets.WINGET_TOKEN }} + snapcraft: + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v7 + with: + merge-multiple: true + - name: Promote snap to stable env: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bd9de25..0619682f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/): ## [Unreleased] +### Added + +- Support VFS for preset previewers that rely on external commands ([#3477]) + ## [v25.12.29] ### Added @@ -1552,6 +1556,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/): [#3313]: https://github.com/sxyazi/yazi/pull/3313 [#3317]: https://github.com/sxyazi/yazi/pull/3317 [#3360]: https://github.com/sxyazi/yazi/pull/3360 +[#3361]: https://github.com/sxyazi/yazi/pull/3361 [#3364]: https://github.com/sxyazi/yazi/pull/3364 [#3369]: https://github.com/sxyazi/yazi/pull/3369 [#3383]: https://github.com/sxyazi/yazi/pull/3383 @@ -1565,3 +1570,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/): [#3429]: https://github.com/sxyazi/yazi/pull/3429 [#3456]: https://github.com/sxyazi/yazi/pull/3456 [#3467]: https://github.com/sxyazi/yazi/pull/3467 +[#3477]: https://github.com/sxyazi/yazi/pull/3477 diff --git a/Cargo.lock b/Cargo.lock index a36d1b28..e3005b52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -186,7 +186,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -500,7 +500,7 @@ checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -621,9 +621,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.62" +version = "4.5.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "004eef6b14ce34759aa7de4aea3217e368f463f46a3ed3764ca4b5a4404003b4" +checksum = "4c0da80818b2d95eca9aa614a30783e42f62bf5fdfee24e68cfb960b071ba8d1" dependencies = [ "clap", ] @@ -657,7 +657,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -974,7 +974,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -998,7 +998,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -1009,7 +1009,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -1047,7 +1047,7 @@ checksum = "780eb241654bf097afb00fc5f054a09b687dad862e485fdcf8399bb056565370" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -1105,7 +1105,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -1115,7 +1115,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -1137,7 +1137,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -1274,7 +1274,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -1300,7 +1300,7 @@ checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -1543,7 +1543,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -1718,7 +1718,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -1923,7 +1923,7 @@ dependencies = [ "indoc", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -1965,7 +1965,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -2377,7 +2377,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -2508,7 +2508,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -2764,7 +2764,7 @@ dependencies = [ "by_address", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -2883,7 +2883,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -2936,7 +2936,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -3111,7 +3111,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -3139,7 +3139,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b" dependencies = [ "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -3486,7 +3486,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -3814,7 +3814,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -4111,7 +4111,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -4133,9 +4133,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.111" +version = "2.0.112" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" +checksum = "21f182278bf2d2bcb3c88b1b08a37df029d71ce3d3ae26168e3c653b213b99d4" dependencies = [ "proc-macro2", "quote", @@ -4269,7 +4269,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -4280,7 +4280,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -4363,7 +4363,7 @@ checksum = "2d2e76690929402faae40aebdda620a2c0e25dd6d3b9afe48867dfd95991f4bd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -4391,7 +4391,7 @@ checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -4488,7 +4488,7 @@ checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -4802,7 +4802,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", "wasm-bindgen-shared", ] @@ -5032,7 +5032,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -5043,7 +5043,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -5054,7 +5054,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -5065,7 +5065,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -5449,7 +5449,7 @@ name = "yazi-codegen" version = "25.12.29" dependencies = [ "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -5863,7 +5863,7 @@ checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] @@ -5877,20 +5877,20 @@ dependencies = [ [[package]] name = "zeroize_derive" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +checksum = "85a5b4158499876c763cb03bc4e49185d3cccbabb15b33c627f7884f43db852e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.112", ] [[package]] name = "zmij" -version = "1.0.2" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4a4e8e9dc5c62d159f04fcdbe07f4c3fb710415aab4754bf11505501e3251d" +checksum = "aac060176f7020d62c3bcc1cdbcec619d54f48b07ad1963a3f80ce7a0c17755f" [[package]] name = "zune-core" diff --git a/yazi-actor/src/lives/file.rs b/yazi-actor/src/lives/file.rs index 12b57fe6..3a41f6bc 100644 --- a/yazi-actor/src/lives/file.rs +++ b/yazi-actor/src/lives/file.rs @@ -19,6 +19,7 @@ pub(super) struct File { v_link_to: Option, v_name: Option, + v_path: Option, v_cache: Option, v_bare: Option, @@ -55,6 +56,7 @@ impl File { v_link_to: None, v_name: None, + v_path: None, v_cache: None, v_bare: None, diff --git a/yazi-binding/src/file.rs b/yazi-binding/src/file.rs index 489252f3..8555d9e5 100644 --- a/yazi-binding/src/file.rs +++ b/yazi-binding/src/file.rs @@ -17,6 +17,7 @@ pub struct File { v_link_to: Option, v_name: Option, + v_path: Option, v_cache: Option, } @@ -37,8 +38,10 @@ impl File { v_cha: None, v_url: None, v_link_to: None, - v_name: None, - v_cache: None, + + v_name: None, + v_path: None, + v_cache: None, } } diff --git a/yazi-binding/src/macros.rs b/yazi-binding/src/macros.rs index 8ad662a7..37e0a13f 100644 --- a/yazi-binding/src/macros.rs +++ b/yazi-binding/src/macros.rs @@ -213,9 +213,14 @@ macro_rules! impl_file_fields { $crate::cached_field!($fields, name, |lua, me| { me.name().map(|s| lua.create_string(s.encoded_bytes())).transpose() }); + $crate::cached_field!($fields, path, |_, me| { + use yazi_fs::FsUrl; + use yazi_shared::url::AsUrl; + Ok($crate::Path::new(me.url.as_url().unified_path())) + }); $crate::cached_field!($fields, cache, |_, me| { use yazi_fs::FsUrl; - Ok(me.url.cache().map($crate::Url::new)) + Ok(me.url.cache().map($crate::Path::new)) }); }; } diff --git a/yazi-binding/src/scheme.rs b/yazi-binding/src/scheme.rs index 8ceecc57..53f686b7 100644 --- a/yazi-binding/src/scheme.rs +++ b/yazi-binding/src/scheme.rs @@ -4,7 +4,7 @@ use mlua::{UserData, UserDataFields, Value}; use yazi_fs::FsScheme; use yazi_shared::scheme::SchemeLike; -use crate::{Url, cached_field}; +use crate::{Path, cached_field}; pub struct Scheme { inner: yazi_shared::scheme::Scheme, @@ -28,7 +28,7 @@ impl Scheme { impl UserData for Scheme { fn add_fields>(fields: &mut F) { cached_field!(fields, kind, |_, me| Ok(me.kind().as_str())); - cached_field!(fields, cache, |_, me| Ok(me.cache().map(Url::new))); + cached_field!(fields, cache, |_, me| Ok(me.cache().map(Path::new))); fields.add_field_method_get("is_virtual", |_, me| Ok(me.is_virtual())); } diff --git a/yazi-binding/src/url.rs b/yazi-binding/src/url.rs index c80ae7c7..44af8778 100644 --- a/yazi-binding/src/url.rs +++ b/yazi-binding/src/url.rs @@ -1,13 +1,15 @@ use std::ops::Deref; use mlua::{AnyUserData, ExternalError, ExternalResult, FromLua, IntoLua, Lua, MetaMethod, UserData, UserDataFields, UserDataMethods, UserDataRef, Value}; -use yazi_fs::{FsHash64, FsHash128}; -use yazi_shared::{path::StripPrefixError, scheme::SchemeCow, strand::{StrandLike, ToStrand}, url::{AsUrl, UrlCow, UrlLike}}; +use yazi_fs::{FsHash64, FsHash128, FsUrl}; +use yazi_shared::{path::{PathLike, StripPrefixError}, scheme::SchemeCow, strand::{StrandLike, ToStrand}, url::{AsUrl, UrlCow, UrlLike}}; use crate::{Path, Scheme, cached_field, deprecate}; pub type UrlRef = UserDataRef; +const EXPECTED: &str = "expected a string, Url, or Path"; + pub struct Url { inner: yazi_shared::url::UrlBuf, @@ -21,6 +23,8 @@ pub struct Url { v_scheme: Option, v_domain: Option, + + v_cache: Option, } impl Deref for Url { @@ -29,10 +33,6 @@ impl Deref for Url { fn deref(&self) -> &Self::Target { &self.inner } } -impl AsRef for Url { - fn as_ref(&self) -> &yazi_shared::url::UrlBuf { &self.inner } -} - impl AsUrl for Url { fn as_url(&self) -> yazi_shared::url::Url<'_> { self.inner.as_url() } } @@ -74,6 +74,8 @@ impl Url { v_scheme: None, v_domain: None, + + v_cache: None, } } @@ -83,8 +85,16 @@ impl Url { lua.create_function(|_, value: Value| { Ok(match value { Value::String(s) => Self::try_from(&*s.as_bytes())?, - Value::UserData(ud) => Self::new(&ud.borrow::()?.inner), - _ => Err("Expected a string or a Url".into_lua_err())?, + Value::UserData(ud) => { + if let Ok(url) = ud.borrow::() { + Self::new(&url.inner) + } else if let Ok(path) = ud.borrow::() { + Self::new(path.as_os().into_lua_err()?) + } else { + Err(EXPECTED.into_lua_err())? + } + } + _ => Err(EXPECTED.into_lua_err())?, }) })?, ) @@ -173,17 +183,19 @@ impl UserData for Url { cached_field!(fields, ext, |lua, me| { me.ext().map(|s| lua.create_string(s.encoded_bytes())).transpose() }); - cached_field!(fields, parent, |_, me| Ok(me.parent().map(Self::new))); cached_field!(fields, urn, |_, me| Ok(Path::new(me.urn()))); cached_field!(fields, base, |_, me| { Ok(Some(me.base()).filter(|u| !u.loc().is_empty()).map(Self::new)) }); + cached_field!(fields, parent, |_, me| Ok(me.parent().map(Self::new))); cached_field!(fields, scheme, |_, me| Ok(Scheme::new(me.scheme()))); cached_field!(fields, domain, |lua, me| { me.scheme().domain().map(|s| lua.create_string(s)).transpose() }); + cached_field!(fields, cache, |_, me| Ok(me.cache().map(Path::new))); + fields.add_field_method_get("frag", |lua, me| { deprecate!(lua, "`frag` property of Url is deprecated and renamed to `domain`, please use the new name instead, in your {}"); me.scheme().domain().map(|s| lua.create_string(s)).transpose() diff --git a/yazi-boot/Cargo.toml b/yazi-boot/Cargo.toml index 1ffda475..c6119444 100644 --- a/yazi-boot/Cargo.toml +++ b/yazi-boot/Cargo.toml @@ -30,7 +30,7 @@ yazi-shared = { path = "../yazi-shared", version = "25.12.29" } # External dependencies clap = { workspace = true } -clap_complete = "4.5.62" +clap_complete = "4.5.64" clap_complete_fig = "4.5.2" clap_complete_nushell = "4.5.10" vergen-gitcl = { version = "1.0.8", features = [ "build", "rustc" ] } diff --git a/yazi-cli/Cargo.toml b/yazi-cli/Cargo.toml index ac72a8b1..06bc49f1 100644 --- a/yazi-cli/Cargo.toml +++ b/yazi-cli/Cargo.toml @@ -44,7 +44,7 @@ yazi-shared = { path = "../yazi-shared", version = "25.12.29" } # External build dependencies anyhow = { workspace = true } clap = { workspace = true } -clap_complete = "4.5.62" +clap_complete = "4.5.64" clap_complete_fig = "4.5.2" clap_complete_nushell = "4.5.10" serde_json = { workspace = true } diff --git a/yazi-codegen/Cargo.toml b/yazi-codegen/Cargo.toml index ffc132d0..bdb491c4 100644 --- a/yazi-codegen/Cargo.toml +++ b/yazi-codegen/Cargo.toml @@ -16,5 +16,5 @@ proc-macro = true [dependencies] # External dependencies -syn = { version = "2.0.111", features = [ "full" ] } +syn = { version = "2.0.112", features = [ "full" ] } quote = "1.0.42" diff --git a/yazi-plugin/preset/plugins/archive.lua b/yazi-plugin/preset/plugins/archive.lua index 596ad1c7..9e075c02 100644 --- a/yazi-plugin/preset/plugins/archive.lua +++ b/yazi-plugin/preset/plugins/archive.lua @@ -2,7 +2,7 @@ local M = {} function M:peek(job) local limit = job.area.h - local files, bound, err = self.list_files({ "-p", tostring(job.file.url) }, job.skip, limit) + local files, bound, err = self.list_files({ "-p", tostring(job.file.path) }, job.skip, limit) if err then return ya.preview_widget(job, err) @@ -168,6 +168,6 @@ end function M.is_encrypted(s) return s:find(" Wrong password", 1, true) end -function M.is_tar(url) return M.list_meta { "-p", tostring(url) } == "tar" end +function M.is_tar(path) return M.list_meta { "-p", tostring(path) } == "tar" end return M diff --git a/yazi-plugin/preset/plugins/empty.lua b/yazi-plugin/preset/plugins/empty.lua index 6d4db81b..d85034a5 100644 --- a/yazi-plugin/preset/plugins/empty.lua +++ b/yazi-plugin/preset/plugins/empty.lua @@ -3,7 +3,7 @@ local M = {} function M.msg(job, s) ya.preview_widget(job, ui.Text(ui.Line(s):reverse()):area(job.area):wrap(ui.Wrap.YES)) end function M:peek(job) - local path = tostring(job.file.url) + local path = tostring(job.file.path) if path:sub(1, 6) ~= "/proc/" then return self.msg(job, "Empty file") end diff --git a/yazi-plugin/preset/plugins/file.lua b/yazi-plugin/preset/plugins/file.lua index ccf091e3..246a79d1 100644 --- a/yazi-plugin/preset/plugins/file.lua +++ b/yazi-plugin/preset/plugins/file.lua @@ -2,7 +2,7 @@ local M = {} function M:peek(job) local cmd = os.getenv("YAZI_FILE_ONE") or "file" - local path = tostring(job.file.cache or job.file.url) + local path = tostring(job.file.path) local output, err = Command(cmd):arg({ "-bL", "--", path }):output() local text diff --git a/yazi-plugin/preset/plugins/font.lua b/yazi-plugin/preset/plugins/font.lua index 070e2534..cb5895fe 100644 --- a/yazi-plugin/preset/plugins/font.lua +++ b/yazi-plugin/preset/plugins/font.lua @@ -33,7 +33,7 @@ function M:preload(job) "-gravity", "center", "-font", - tostring(job.file.url), + tostring(job.file.path), "-pointsize", 64, "xc:white", diff --git a/yazi-plugin/preset/plugins/json.lua b/yazi-plugin/preset/plugins/json.lua index dfccd22a..39842ea5 100644 --- a/yazi-plugin/preset/plugins/json.lua +++ b/yazi-plugin/preset/plugins/json.lua @@ -2,7 +2,7 @@ local M = {} function M:peek(job) local child = Command("jq") - :arg({ "-b", "-C", "--tab", ".", tostring(job.file.url) }) + :arg({ "-b", "-C", "--tab", ".", tostring(job.file.path) }) :stdout(Command.PIPED) :stderr(Command.PIPED) :spawn() diff --git a/yazi-plugin/preset/plugins/magick.lua b/yazi-plugin/preset/plugins/magick.lua index ce3e7e49..80257838 100644 --- a/yazi-plugin/preset/plugins/magick.lua +++ b/yazi-plugin/preset/plugins/magick.lua @@ -25,7 +25,7 @@ function M:preload(job) return true end - local cmd = M.with_limit():arg(tostring(job.file.url)) + local cmd = M.with_limit():arg(tostring(job.file.path)) if job.args.flatten then cmd:arg("-flatten") end diff --git a/yazi-plugin/preset/plugins/mime-local.lua b/yazi-plugin/preset/plugins/mime-local.lua index 1e2cfdcb..9f4bb42b 100644 --- a/yazi-plugin/preset/plugins/mime-local.lua +++ b/yazi-plugin/preset/plugins/mime-local.lua @@ -9,7 +9,7 @@ function M:fetch(job) if file.cache then urls[i], paths[i] = tostring(file.url), tostring(file.cache) else - paths[i] = tostring(file.url.path) + paths[i] = tostring(file.path) end end diff --git a/yazi-plugin/preset/plugins/mime-remote.lua b/yazi-plugin/preset/plugins/mime-remote.lua index d936fe5c..b6f0223c 100644 --- a/yazi-plugin/preset/plugins/mime-remote.lua +++ b/yazi-plugin/preset/plugins/mime-remote.lua @@ -21,7 +21,7 @@ function M:fetch(job) -- Skip dummy files elseif not file.cache then unknown[#unknown + 1] = file - elseif not fs.cha(file.cache) then + elseif not fs.cha(Url(file.cache)) then updates[file.url], state[i] = "vfs/absent", true elseif stale_cache(file) then updates[file.url], state[i] = "vfs/stale", true diff --git a/yazi-plugin/preset/plugins/pdf.lua b/yazi-plugin/preset/plugins/pdf.lua index e19ea898..7c84ca3f 100644 --- a/yazi-plugin/preset/plugins/pdf.lua +++ b/yazi-plugin/preset/plugins/pdf.lua @@ -40,7 +40,7 @@ function M:preload(job) "-l", job.skip + 1, "-singlefile", "-jpeg", "-jpegopt", "quality=" .. rt.preview.image_quality, - tostring(job.file.url), tostring(cache), + tostring(job.file.path), tostring(cache), }) :output() diff --git a/yazi-plugin/preset/plugins/svg.lua b/yazi-plugin/preset/plugins/svg.lua index 6d90585a..9bf75f58 100644 --- a/yazi-plugin/preset/plugins/svg.lua +++ b/yazi-plugin/preset/plugins/svg.lua @@ -37,7 +37,7 @@ function M:preload(job) cmd = cmd:memory(rt.tasks.image_alloc) end - local child, err = cmd:arg({ tostring(job.file.url), tostring(cache) }):spawn() + local child, err = cmd:arg({ tostring(job.file.path), tostring(cache) }):spawn() if not child then return true, Err("Failed to start `resvg`, error: %s", err) end diff --git a/yazi-plugin/preset/plugins/video.lua b/yazi-plugin/preset/plugins/video.lua index 890c48cd..0d21581d 100644 --- a/yazi-plugin/preset/plugins/video.lua +++ b/yazi-plugin/preset/plugins/video.lua @@ -38,7 +38,7 @@ function M:preload(job) return true end - local meta, err = self.list_meta(job.file.url, "format=duration:stream_disposition=attached_pic") + local meta, err = self.list_meta(job.file.path, "format=duration:stream_disposition=attached_pic") if not meta then return true, err elseif not meta.format.duration then @@ -59,7 +59,7 @@ function M:preload(job) if percent ~= 0 then cmd:arg { "-ss", math.floor(meta.format.duration * percent / 100) } end - cmd:arg { "-skip_frame", "nokey", "-i", tostring(job.file.url) } + cmd:arg { "-skip_frame", "nokey", "-i", tostring(job.file.path) } if percent == 0 then cmd:arg { "-map", "disp:attached_pic" } end @@ -101,7 +101,7 @@ function M:spot(job) end function M:spot_base(job) - local meta, err = self.list_meta(job.file.url, "format=duration:stream=codec_name,codec_type,width,height") + local meta, err = self.list_meta(job.file.path, "format=duration:stream=codec_name,codec_type,width,height") if not meta then ya.err(tostring(err)) return {} @@ -126,13 +126,13 @@ function M:spot_base(job) return rows end -function M.list_meta(url, entries) +function M.list_meta(path, entries) local cmd = Command("ffprobe"):arg { "-v", "quiet" } if not entries:find("attached_pic", 1, true) then cmd:arg { "-select_streams", "v" } end - local output, err = cmd:arg({ "-show_entries", entries, "-of", "json=c=1", tostring(url) }):output() + local output, err = cmd:arg({ "-show_entries", entries, "-of", "json=c=1", tostring(path) }):output() if not output then return nil, Err("Failed to start `ffprobe`, error: %s", err) end diff --git a/yazi-shared/src/path/buf.rs b/yazi-shared/src/path/buf.rs index 1699e061..1ef141e5 100644 --- a/yazi-shared/src/path/buf.rs +++ b/yazi-shared/src/path/buf.rs @@ -1,4 +1,4 @@ -use std::{ffi::OsString, hash::{Hash, Hasher}}; +use std::{borrow::Cow, ffi::OsString, hash::{Hash, Hasher}}; use hashbrown::Equivalent; @@ -23,6 +23,10 @@ impl From> for PathBufDyn { fn from(value: PathDyn<'_>) -> Self { value.to_owned() } } +impl From> for PathBufDyn { + fn from(value: Cow<'_, std::path::Path>) -> Self { Self::Os(value.into_owned()) } +} + impl TryFrom for std::path::PathBuf { type Error = PathDynError;