mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-28 19:24:06 +03:00
feat: add loading state to directories (#904)
This commit is contained in:
parent
3c67cae42d
commit
5fc2789c78
85
Cargo.lock
generated
85
Cargo.lock
generated
@ -120,9 +120,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.81"
|
||||
version = "1.0.82"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247"
|
||||
checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519"
|
||||
|
||||
[[package]]
|
||||
name = "arc-swap"
|
||||
@ -269,9 +269,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.90"
|
||||
version = "1.0.91"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5"
|
||||
checksum = "1fd97381a8cc6493395a5afc4c691c1084b3768db713b73aa215217aa245d153"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
@ -310,14 +310,14 @@ dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim 0.11.0",
|
||||
"strsim 0.11.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_complete"
|
||||
version = "4.5.1"
|
||||
version = "4.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "885e4d7d5af40bfb99ae6f9433e292feac98d452dcb3ec3d25dfe7552b77da8c"
|
||||
checksum = "dd79504325bf38b10165b02e89b4347300f855f273c4cb30c4a3209e6583275e"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
@ -351,7 +351,7 @@ dependencies = [
|
||||
"heck 0.5.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.57",
|
||||
"syn 2.0.58",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -527,7 +527,7 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim 0.10.0",
|
||||
"syn 2.0.57",
|
||||
"syn 2.0.58",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -538,7 +538,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn 2.0.57",
|
||||
"syn 2.0.58",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -781,7 +781,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.57",
|
||||
"syn 2.0.58",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1204,9 +1204,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "mlua"
|
||||
version = "0.9.6"
|
||||
version = "0.9.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "868d02cb5eb97761bbf6bd6922c1c7a88b8ea252bbf43bd8350a0bf8497a1fc0"
|
||||
checksum = "6d9bed6bce296397a9d6a86f995dd10a547a4e6949825d45225906bdcbfe7367"
|
||||
dependencies = [
|
||||
"bstr",
|
||||
"erased-serde",
|
||||
@ -1222,9 +1222,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "mlua-sys"
|
||||
version = "0.5.1"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2847b42764435201d8cbee1f517edb79c4cca4181877b90047587c89e1b7bce4"
|
||||
checksum = "d16a9ba1dd2c6ac971b204262d434c24d65067038598f0638b64e5dca28d52b8"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cfg-if",
|
||||
@ -1245,7 +1245,7 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"syn 2.0.57",
|
||||
"syn 2.0.58",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1538,9 +1538,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.35"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
@ -1713,7 +1713,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.57",
|
||||
"syn 2.0.58",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1863,9 +1863,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.0"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
@ -1886,7 +1886,7 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustversion",
|
||||
"syn 2.0.57",
|
||||
"syn 2.0.58",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1902,9 +1902,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.57"
|
||||
version = "2.0.58"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35"
|
||||
checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -1949,7 +1949,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.57",
|
||||
"syn 2.0.58",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2068,7 +2068,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.57",
|
||||
"syn 2.0.58",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2161,7 +2161,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.57",
|
||||
"syn 2.0.58",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2283,9 +2283,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "validator"
|
||||
version = "0.17.0"
|
||||
version = "0.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da339118f018cc70ebf01fafc103360528aad53717e4bf311db929cb01cb9345"
|
||||
checksum = "db79c75af171630a3148bd3e6d7c4f42b6a9a014c2945bc5ed0020cbb8d9478e"
|
||||
dependencies = [
|
||||
"idna",
|
||||
"once_cell",
|
||||
@ -2299,16 +2299,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "validator_derive"
|
||||
version = "0.17.0"
|
||||
version = "0.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76e88ea23b8f5e59230bff8a2f03c0ee0054a61d5b8343a38946bcd406fe624c"
|
||||
checksum = "55591299b7007f551ed1eb79a684af7672c19c3193fb9e0a31936987bb2438ec"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"once_cell",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"syn 2.0.57",
|
||||
"syn 2.0.58",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2372,7 +2372,7 @@ dependencies = [
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.57",
|
||||
"syn 2.0.58",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
@ -2394,7 +2394,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.57",
|
||||
"syn 2.0.58",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
@ -2719,10 +2719,8 @@ dependencies = [
|
||||
"anyhow",
|
||||
"arc-swap",
|
||||
"crossterm",
|
||||
"futures",
|
||||
"glob",
|
||||
"indexmap",
|
||||
"md-5",
|
||||
"ratatui",
|
||||
"serde",
|
||||
"shell-words",
|
||||
@ -2741,7 +2739,6 @@ dependencies = [
|
||||
"clipboard-win",
|
||||
"crossterm",
|
||||
"futures",
|
||||
"indexmap",
|
||||
"libc",
|
||||
"notify",
|
||||
"parking_lot",
|
||||
@ -2776,7 +2773,6 @@ dependencies = [
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
"uzers",
|
||||
"yazi-boot",
|
||||
"yazi-shared",
|
||||
@ -2803,7 +2799,6 @@ dependencies = [
|
||||
"tracing",
|
||||
"tracing-appender",
|
||||
"tracing-subscriber",
|
||||
"unicode-width",
|
||||
"yazi-adaptor",
|
||||
"yazi-boot",
|
||||
"yazi-config",
|
||||
@ -2811,7 +2806,6 @@ dependencies = [
|
||||
"yazi-dds",
|
||||
"yazi-plugin",
|
||||
"yazi-proxy",
|
||||
"yazi-scheduler",
|
||||
"yazi-shared",
|
||||
]
|
||||
|
||||
@ -2821,8 +2815,6 @@ version = "0.2.4"
|
||||
dependencies = [
|
||||
"ansi-to-tui",
|
||||
"anyhow",
|
||||
"arc-swap",
|
||||
"crossterm",
|
||||
"futures",
|
||||
"md-5",
|
||||
"mlua",
|
||||
@ -2870,18 +2862,13 @@ version = "0.2.4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-priority-channel",
|
||||
"base64 0.22.0",
|
||||
"crossterm",
|
||||
"futures",
|
||||
"libc",
|
||||
"parking_lot",
|
||||
"regex",
|
||||
"scopeguard",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tracing",
|
||||
"trash",
|
||||
"yazi-adaptor",
|
||||
"yazi-config",
|
||||
"yazi-dds",
|
||||
"yazi-plugin",
|
||||
@ -2925,7 +2912,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.57",
|
||||
"syn 2.0.58",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -13,7 +13,7 @@ yazi-config = { path = "../yazi-config", version = "0.2.4" }
|
||||
yazi-shared = { path = "../yazi-shared", version = "0.2.4" }
|
||||
|
||||
# External dependencies
|
||||
anyhow = "1.0.81"
|
||||
anyhow = "1.0.82"
|
||||
arc-swap = "1.7.1"
|
||||
base64 = "0.22.0"
|
||||
color_quant = "1.1.0"
|
||||
|
@ -19,7 +19,7 @@ serde = { version = "1.0.197", features = [ "derive" ] }
|
||||
|
||||
[build-dependencies]
|
||||
clap = { version = "4.5.4", features = [ "derive" ] }
|
||||
clap_complete = "4.5.1"
|
||||
clap_complete = "4.5.2"
|
||||
clap_complete_nushell = "4.5.1"
|
||||
clap_complete_fig = "4.5.0"
|
||||
vergen = { version = "8.3.1", features = [ "build", "git", "gitcl" ] }
|
||||
|
@ -12,15 +12,13 @@ repository = "https://github.com/sxyazi/yazi"
|
||||
yazi-shared = { path = "../yazi-shared", version = "0.2.4" }
|
||||
|
||||
# External dependencies
|
||||
anyhow = "1.0.81"
|
||||
anyhow = "1.0.82"
|
||||
arc-swap = "1.7.1"
|
||||
crossterm = "0.27.0"
|
||||
futures = "0.3.30"
|
||||
glob = "0.3.1"
|
||||
indexmap = "2.2.6"
|
||||
md-5 = "0.10.6"
|
||||
ratatui = "0.26.1"
|
||||
serde = { version = "1.0.197", features = [ "derive" ] }
|
||||
shell-words = "1.1.0"
|
||||
toml = { version = "0.8.12", features = [ "preserve_order" ] }
|
||||
validator = { version = "0.17.0", features = [ "derive" ] }
|
||||
validator = { version = "0.18.1", features = [ "derive" ] }
|
||||
|
@ -27,8 +27,8 @@ find_position = { fg = "magenta", bg = "reset", bold = true, italic = true }
|
||||
# Marker
|
||||
marker_copied = { fg = "lightgreen", bg = "lightgreen" }
|
||||
marker_cut = { fg = "lightred", bg = "lightred" }
|
||||
marker_marked = { fg = "lightyellow", bg = "lightyellow" }
|
||||
marker_selected = { fg = "lightblue", bg = "lightblue" }
|
||||
marker_marked = { fg = "lightcyan", bg = "lightcyan" }
|
||||
marker_selected = { fg = "lightyellow", bg = "lightyellow" }
|
||||
|
||||
# Tab
|
||||
tab_active = { reversed = true }
|
||||
|
@ -19,12 +19,11 @@ yazi-scheduler = { path = "../yazi-scheduler", version = "0.2.4" }
|
||||
yazi-shared = { path = "../yazi-shared", version = "0.2.4" }
|
||||
|
||||
# External dependencies
|
||||
anyhow = "1.0.81"
|
||||
anyhow = "1.0.82"
|
||||
base64 = "0.22.0"
|
||||
bitflags = "2.5.0"
|
||||
crossterm = "0.27.0"
|
||||
futures = "0.3.30"
|
||||
indexmap = "2.2.6"
|
||||
notify = { version = "6.1.1", default-features = false, features = [ "macos_fsevent" ] }
|
||||
parking_lot = "0.12.1"
|
||||
ratatui = "0.26.1"
|
||||
|
@ -58,12 +58,9 @@ impl Clipboard {
|
||||
|
||||
use crossterm::execute;
|
||||
use tokio::{io::AsyncWriteExt, process::Command};
|
||||
use yazi_shared::in_ssh_connection;
|
||||
|
||||
s.as_ref().clone_into(&mut self.content.lock());
|
||||
if in_ssh_connection() {
|
||||
execute!(BufWriter::new(stderr()), osc52::SetClipboard::new(s.as_ref())).ok();
|
||||
}
|
||||
execute!(BufWriter::new(stderr()), osc52::SetClipboard::new(s.as_ref())).ok();
|
||||
|
||||
let all = [
|
||||
("pbcopy", &[][..]),
|
||||
|
@ -1,9 +1,8 @@
|
||||
use std::{collections::{HashMap, HashSet}, mem, ops::Deref, sync::atomic::Ordering};
|
||||
use std::{collections::{HashMap, HashSet}, fs::Metadata, mem, ops::Deref, sync::atomic::Ordering, time::SystemTime};
|
||||
|
||||
use anyhow::Result;
|
||||
use tokio::{fs::{self, DirEntry}, select, sync::mpsc::{self, UnboundedReceiver}};
|
||||
use yazi_config::{manager::SortBy, MANAGER};
|
||||
use yazi_shared::fs::{File, Url, FILES_TICKET};
|
||||
use yazi_shared::fs::{accessible, File, FilesOp, Url, FILES_TICKET};
|
||||
|
||||
use super::{FilesSorter, Filter};
|
||||
|
||||
@ -46,7 +45,7 @@ impl Deref for Files {
|
||||
}
|
||||
|
||||
impl Files {
|
||||
pub async fn from_dir(url: &Url) -> Result<UnboundedReceiver<File>> {
|
||||
pub async fn from_dir(url: &Url) -> std::io::Result<UnboundedReceiver<File>> {
|
||||
let mut it = fs::read_dir(url).await?;
|
||||
let (tx, rx) = mpsc::unbounded_channel();
|
||||
|
||||
@ -65,7 +64,7 @@ impl Files {
|
||||
Ok(rx)
|
||||
}
|
||||
|
||||
pub async fn from_dir_bulk(url: &Url) -> Result<Vec<File>> {
|
||||
pub async fn from_dir_bulk(url: &Url) -> std::io::Result<Vec<File>> {
|
||||
let mut it = fs::read_dir(url).await?;
|
||||
let mut items = Vec::with_capacity(5000);
|
||||
while let Ok(Some(item)) = it.next_entry().await {
|
||||
@ -92,6 +91,25 @@ impl Files {
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn assert_stale(url: &Url, mtime: Option<SystemTime>) -> Option<Metadata> {
|
||||
match fs::metadata(url).await {
|
||||
Ok(m) if !m.is_dir() => {
|
||||
// FIXME: use `ErrorKind::NotADirectory` instead once it gets stabilized
|
||||
FilesOp::IOErr(url.clone(), std::io::ErrorKind::AlreadyExists).emit();
|
||||
}
|
||||
Ok(m) if mtime == m.modified().ok() => {}
|
||||
Ok(m) => return Some(m),
|
||||
Err(e) => {
|
||||
if accessible(url).await {
|
||||
FilesOp::IOErr(url.clone(), e.kind()).emit();
|
||||
} else if let Some(p) = url.parent_url() {
|
||||
FilesOp::Deleting(p, vec![url.clone()]).emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl Files {
|
||||
@ -139,6 +157,12 @@ impl Files {
|
||||
self.sizes.extend(sizes);
|
||||
}
|
||||
|
||||
pub fn update_ioerr(&mut self) {
|
||||
self.ticket = FILES_TICKET.fetch_add(1, Ordering::Relaxed);
|
||||
self.hidden.clear();
|
||||
self.items.clear();
|
||||
}
|
||||
|
||||
pub fn update_creating(&mut self, files: Vec<File>) {
|
||||
if files.is_empty() {
|
||||
return;
|
||||
|
@ -28,7 +28,7 @@ impl From<&Url> for Folder {
|
||||
|
||||
impl Folder {
|
||||
pub fn update(&mut self, op: FilesOp) -> bool {
|
||||
let revision = self.files.revision;
|
||||
let (stage, revision) = (self.stage, self.files.revision);
|
||||
match op {
|
||||
FilesOp::Full(_, _, mtime) => {
|
||||
(self.mtime, self.stage) = (mtime, FolderStage::Loaded);
|
||||
@ -39,6 +39,9 @@ impl Folder {
|
||||
FilesOp::Done(_, mtime, ticket) if ticket == self.files.ticket() => {
|
||||
(self.mtime, self.stage) = (mtime, FolderStage::Loaded);
|
||||
}
|
||||
FilesOp::IOErr(_, kind) => {
|
||||
(self.mtime, self.stage) = (None, FolderStage::Failed(kind));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@ -47,6 +50,7 @@ impl Folder {
|
||||
FilesOp::Part(_, files, ticket) => self.files.update_part(files, ticket),
|
||||
FilesOp::Done(..) => {}
|
||||
FilesOp::Size(_, sizes) => self.files.update_size(sizes),
|
||||
FilesOp::IOErr(..) => self.files.update_ioerr(),
|
||||
|
||||
FilesOp::Creating(_, files) => self.files.update_creating(files),
|
||||
FilesOp::Deleting(_, urls) => self.files.update_deleting(urls),
|
||||
@ -55,7 +59,7 @@ impl Folder {
|
||||
}
|
||||
|
||||
self.arrow(0);
|
||||
self.files.revision != revision
|
||||
(stage, revision) != (self.stage, self.files.revision)
|
||||
}
|
||||
|
||||
pub fn arrow(&mut self, step: impl Into<Step>) -> bool {
|
||||
|
@ -3,5 +3,5 @@ pub enum FolderStage {
|
||||
#[default]
|
||||
Loading,
|
||||
Loaded,
|
||||
Failed,
|
||||
Failed(std::io::ErrorKind),
|
||||
}
|
||||
|
@ -1,13 +1,28 @@
|
||||
use std::env;
|
||||
|
||||
use crossterm::{execute, terminal::SetTitle};
|
||||
use yazi_shared::event::Cmd;
|
||||
|
||||
use crate::{manager::Manager, tasks::Tasks};
|
||||
|
||||
impl Manager {
|
||||
fn title(&self) -> String {
|
||||
#[cfg(unix)]
|
||||
let home = env::var_os("HOME").unwrap_or_default();
|
||||
#[cfg(windows)]
|
||||
let home = env::var_os("USERPROFILE").unwrap_or_default();
|
||||
|
||||
if let Some(p) = self.cwd().strip_prefix(home) {
|
||||
format!("Yazi: ~/{}", p.display())
|
||||
} else {
|
||||
format!("Yazi: {}", self.cwd().display())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn refresh(&mut self, _: Cmd, tasks: &Tasks) {
|
||||
env::set_current_dir(self.cwd()).ok();
|
||||
env::set_var("PWD", self.cwd());
|
||||
execute!(std::io::stderr(), SetTitle(self.title())).ok();
|
||||
|
||||
self.active_mut().apply_files_attrs();
|
||||
|
||||
|
@ -71,18 +71,7 @@ impl Watcher {
|
||||
}
|
||||
|
||||
async fn go(url: Url, mtime: Option<SystemTime>) {
|
||||
let Ok(meta) = fs::metadata(&url).await else {
|
||||
if let Ok(m) = fs::symlink_metadata(&url).await {
|
||||
FilesOp::Full(url, vec![], m.modified().ok()).emit();
|
||||
} else if let Some(p) = url.parent_url() {
|
||||
FilesOp::Deleting(p, vec![url]).emit();
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
if meta.modified().ok() == mtime {
|
||||
return;
|
||||
}
|
||||
let Some(meta) = Files::assert_stale(&url, mtime).await else { return };
|
||||
|
||||
if let Ok(files) = Files::from_dir_bulk(&url).await {
|
||||
FilesOp::Full(url, files, meta.modified().ok()).emit();
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use tokio::{fs, pin, task::JoinHandle};
|
||||
use tokio::{pin, task::JoinHandle};
|
||||
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use yazi_adaptor::ADAPTOR;
|
||||
@ -54,23 +54,8 @@ impl Preview {
|
||||
self.folder_loader = Some((
|
||||
url.clone(),
|
||||
tokio::spawn(async move {
|
||||
let Ok(meta) = fs::metadata(&url).await else {
|
||||
if let Ok(m) = fs::symlink_metadata(&url).await {
|
||||
FilesOp::Full(url, vec![], m.modified().ok()).emit();
|
||||
} else if let Some(p) = url.parent_url() {
|
||||
FilesOp::Deleting(p, vec![url]).emit();
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
if meta.modified().ok() == mtime {
|
||||
return;
|
||||
}
|
||||
|
||||
let Ok(rx) = Files::from_dir(&url).await else {
|
||||
FilesOp::Full(url, vec![], meta.modified().ok()).emit();
|
||||
return;
|
||||
};
|
||||
let Some(meta) = Files::assert_stale(&url, mtime).await else { return };
|
||||
let Ok(rx) = Files::from_dir(&url).await else { return };
|
||||
|
||||
let stream =
|
||||
UnboundedReceiverStream::new(rx).chunks_timeout(50000, Duration::from_millis(500));
|
||||
|
@ -13,8 +13,8 @@ yazi-boot = { path = "../yazi-boot", version = "0.2.4" }
|
||||
yazi-shared = { path = "../yazi-shared", version = "0.2.4" }
|
||||
|
||||
# External dependencies
|
||||
anyhow = "1.0.81"
|
||||
mlua = { version = "0.9.6", features = [ "lua54", "vendored" ] }
|
||||
anyhow = "1.0.82"
|
||||
mlua = { version = "0.9.7", features = [ "lua54", "vendored" ] }
|
||||
parking_lot = "0.12.1"
|
||||
serde = { version = "1.0.197", features = [ "derive" ] }
|
||||
serde_json = "1.0.115"
|
||||
@ -22,8 +22,5 @@ tokio = { version = "1.37.0", features = [ "full" ] }
|
||||
tokio-stream = "0.1.15"
|
||||
tokio-util = "0.7.10"
|
||||
|
||||
# Logging
|
||||
tracing = { version = "0.1.40", features = [ "max_level_debug", "release_max_level_warn" ] }
|
||||
|
||||
[target."cfg(unix)".dependencies]
|
||||
uzers = "0.11.3"
|
||||
|
@ -16,22 +16,20 @@ yazi-core = { path = "../yazi-core", version = "0.2.4" }
|
||||
yazi-dds = { path = "../yazi-dds", version = "0.2.4" }
|
||||
yazi-plugin = { path = "../yazi-plugin", version = "0.2.4" }
|
||||
yazi-proxy = { path = "../yazi-proxy", version = "0.2.4" }
|
||||
yazi-scheduler = { path = "../yazi-scheduler", version = "0.2.4" }
|
||||
yazi-shared = { path = "../yazi-shared", version = "0.2.4" }
|
||||
|
||||
# External dependencies
|
||||
anyhow = "1.0.81"
|
||||
anyhow = "1.0.82"
|
||||
better-panic = "0.3.0"
|
||||
crossterm = { version = "0.27.0", features = [ "event-stream" ] }
|
||||
fdlimit = "0.3.0"
|
||||
futures = "0.3.30"
|
||||
mlua = { version = "0.9.6", features = [ "lua54", "vendored" ] }
|
||||
mlua = { version = "0.9.7", features = [ "lua54", "vendored" ] }
|
||||
ratatui = "0.26.1"
|
||||
scopeguard = "1.2.0"
|
||||
syntect = { version = "5.2.0", default-features = false, features = [ "parsing", "plist-load", "regex-onig" ] }
|
||||
tokio = { version = "1.37.0", features = [ "full" ] }
|
||||
tokio-util = "0.7.10"
|
||||
unicode-width = "0.1.11"
|
||||
|
||||
# Logging
|
||||
tracing = { version = "0.1.40", features = [ "max_level_debug", "release_max_level_warn" ] }
|
||||
|
@ -56,7 +56,7 @@ impl Folder {
|
||||
lua.create_string(match me {
|
||||
Loading => "loading",
|
||||
Loaded => "loaded",
|
||||
Failed => "failed",
|
||||
Failed(_) => "failed",
|
||||
})
|
||||
});
|
||||
})?;
|
||||
|
@ -18,12 +18,10 @@ yazi-shared = { path = "../yazi-shared", version = "0.2.4" }
|
||||
|
||||
# External dependencies
|
||||
ansi-to-tui = "3.1.0"
|
||||
anyhow = "1.0.81"
|
||||
arc-swap = "1.7.1"
|
||||
crossterm = "0.27.0"
|
||||
anyhow = "1.0.82"
|
||||
futures = "0.3.30"
|
||||
md-5 = "0.10.6"
|
||||
mlua = { version = "0.9.6", features = [ "lua54", "vendored", "serialize", "macros", "async" ] }
|
||||
mlua = { version = "0.9.7", features = [ "lua54", "vendored", "serialize", "macros", "async" ] }
|
||||
parking_lot = "0.12.1"
|
||||
ratatui = "0.26.1"
|
||||
serde = "1.0.197"
|
||||
|
@ -13,6 +13,6 @@ yazi-config = { path = "../yazi-config", version = "0.2.4" }
|
||||
yazi-shared = { path = "../yazi-shared", version = "0.2.4" }
|
||||
|
||||
# External dependencies
|
||||
anyhow = "1.0.81"
|
||||
mlua = { version = "0.9.6", features = [ "lua54", "vendored" ] }
|
||||
anyhow = "1.0.82"
|
||||
mlua = { version = "0.9.7", features = [ "lua54", "vendored" ] }
|
||||
tokio = { version = "1.37.0", features = [ "full" ] }
|
||||
|
@ -9,7 +9,6 @@ homepage = "https://yazi-rs.github.io"
|
||||
repository = "https://github.com/sxyazi/yazi"
|
||||
|
||||
[dependencies]
|
||||
yazi-adaptor = { path = "../yazi-adaptor", version = "0.2.4" }
|
||||
yazi-config = { path = "../yazi-config", version = "0.2.4" }
|
||||
yazi-dds = { path = "../yazi-dds", version = "0.2.4" }
|
||||
yazi-plugin = { path = "../yazi-plugin", version = "0.2.4" }
|
||||
@ -17,16 +16,12 @@ yazi-proxy = { path = "../yazi-proxy", version = "0.2.4" }
|
||||
yazi-shared = { path = "../yazi-shared", version = "0.2.4" }
|
||||
|
||||
# External dependencies
|
||||
anyhow = "1.0.81"
|
||||
anyhow = "1.0.82"
|
||||
async-priority-channel = "0.2.0"
|
||||
base64 = "0.22.0"
|
||||
crossterm = "0.27.0"
|
||||
futures = "0.3.30"
|
||||
parking_lot = "0.12.1"
|
||||
regex = "1.10.4"
|
||||
scopeguard = "1.2.0"
|
||||
tokio = { version = "1.37.0", features = [ "full" ] }
|
||||
tokio-stream = "0.1.15"
|
||||
|
||||
# Logging
|
||||
tracing = { version = "0.1.40", features = [ "max_level_debug", "release_max_level_warn" ] }
|
||||
|
@ -9,7 +9,7 @@ homepage = "https://yazi-rs.github.io"
|
||||
repository = "https://github.com/sxyazi/yazi"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.81"
|
||||
anyhow = "1.0.82"
|
||||
bitflags = "2.5.0"
|
||||
crossterm = "0.27.0"
|
||||
dirs = "5.0.1"
|
||||
|
@ -11,6 +11,7 @@ pub enum FilesOp {
|
||||
Part(Url, Vec<File>, u64),
|
||||
Done(Url, Option<SystemTime>, u64),
|
||||
Size(Url, HashMap<Url, u64>),
|
||||
IOErr(Url, std::io::ErrorKind),
|
||||
|
||||
Creating(Url, Vec<File>),
|
||||
Deleting(Url, Vec<Url>),
|
||||
@ -26,6 +27,7 @@ impl FilesOp {
|
||||
Self::Part(url, ..) => url,
|
||||
Self::Done(url, ..) => url,
|
||||
Self::Size(url, _) => url,
|
||||
Self::IOErr(url, _) => url,
|
||||
|
||||
Self::Creating(url, _) => url,
|
||||
Self::Deleting(url, _) => url,
|
||||
@ -81,6 +83,7 @@ impl FilesOp {
|
||||
Self::Part(_, files, ticket) => Self::Part(u, files!(files), *ticket),
|
||||
Self::Done(_, mtime, ticket) => Self::Done(u, *mtime, *ticket),
|
||||
Self::Size(_, map) => Self::Size(u, map.iter().map(|(k, v)| (new!(k), *v)).collect()),
|
||||
Self::IOErr(_, err) => Self::IOErr(u, *err),
|
||||
|
||||
Self::Creating(_, files) => Self::Creating(u, files!(files)),
|
||||
Self::Deleting(_, urls) => Self::Deleting(u, urls.iter().map(|u| new!(u)).collect()),
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::{io::{self, stderr, BufWriter, Stderr, Write}, mem, ops::{Deref, DerefMut}, sync::atomic::{AtomicBool, Ordering}};
|
||||
|
||||
use anyhow::Result;
|
||||
use crossterm::{cursor::{RestorePosition, SavePosition}, event::{DisableBracketedPaste, DisableFocusChange, EnableBracketedPaste, EnableFocusChange, KeyboardEnhancementFlags, PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags}, execute, queue, style::Print, terminal::{disable_raw_mode, enable_raw_mode, Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen, WindowSize}};
|
||||
use crossterm::{cursor::{RestorePosition, SavePosition}, event::{DisableBracketedPaste, DisableFocusChange, EnableBracketedPaste, EnableFocusChange, KeyboardEnhancementFlags, PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags}, execute, queue, style::Print, terminal::{disable_raw_mode, enable_raw_mode, Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen, SetTitle, WindowSize}};
|
||||
use ratatui::{backend::CrosstermBackend, buffer::Buffer, layout::Rect, CompletedFrame, Frame, Terminal};
|
||||
|
||||
static CSI_U: AtomicBool = AtomicBool::new(false);
|
||||
@ -73,6 +73,7 @@ impl Term {
|
||||
|
||||
execute!(
|
||||
stderr(),
|
||||
SetTitle(""),
|
||||
DisableFocusChange,
|
||||
DisableBracketedPaste,
|
||||
LeaveAlternateScreen,
|
||||
|
Loading…
Reference in New Issue
Block a user