Skip to content

Commit

Permalink
fix: choose a more conservative macro_workers value to ensure concu…
Browse files Browse the repository at this point in the history
…rrency safety with certain USB flash drives (#2040)
  • Loading branch information
sxyazi authored Dec 14, 2024
1 parent c78f39b commit 196a46c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions yazi-config/preset/yazi-default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ rules = [

[tasks]
micro_workers = 10
macro_workers = 25
bizarre_retry = 5
macro_workers = 10
bizarre_retry = 3
image_alloc = 536870912 # 512MB
image_bound = [ 0, 0 ]
suppress_preload = false
Expand Down
10 changes: 10 additions & 0 deletions yazi-fs/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ fn _expand_path(p: &Path) -> PathBuf {
}
}

pub fn skip_path(p: &Path, u: usize) -> &Path {
let mut it = p.components();
for _ in 0..u {
if it.next().is_none() {
return Path::new("");
}
}
it.as_path()
}

pub async fn unique_name<F>(u: Url, append: F) -> io::Result<Url>
where
F: Future<Output = bool>,
Expand Down
8 changes: 4 additions & 4 deletions yazi-scheduler/src/file/file.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::{borrow::Cow, collections::VecDeque, path::{Path, PathBuf}};
use std::{borrow::Cow, collections::VecDeque, path::Path};

use anyhow::{Result, anyhow};
use tokio::{fs::{self, DirEntry}, io::{self, ErrorKind::{AlreadyExists, NotFound}}, sync::mpsc};
use tracing::warn;
use yazi_config::TASKS;
use yazi_fs::{Cha, calculate_size, copy_with_progress, maybe_exists, ok_or_not_found, path_relative_to};
use yazi_fs::{Cha, calculate_size, copy_with_progress, maybe_exists, ok_or_not_found, path_relative_to, skip_path};
use yazi_shared::url::Url;

use super::{FileOp, FileOpDelete, FileOpHardlink, FileOpLink, FileOpPaste, FileOpTrash};
Expand Down Expand Up @@ -190,7 +190,7 @@ impl File {
let mut dirs = VecDeque::from([task.from.clone()]);

while let Some(src) = dirs.pop_front() {
let dest = root.join(src.components().skip(skip).collect::<PathBuf>());
let dest = root.join(skip_path(&src, skip));
continue_unless_ok!(match fs::create_dir(&dest).await {
Err(e) if e.kind() != AlreadyExists => Err(e),
_ => Ok(()),
Expand Down Expand Up @@ -261,7 +261,7 @@ impl File {
let mut dirs = VecDeque::from([task.from.clone()]);

while let Some(src) = dirs.pop_front() {
let dest = root.join(src.components().skip(skip).collect::<PathBuf>());
let dest = root.join(skip_path(&src, skip));
continue_unless_ok!(match fs::create_dir(&dest).await {
Err(e) if e.kind() != AlreadyExists => Err(e),
_ => Ok(()),
Expand Down

0 comments on commit 196a46c

Please sign in to comment.