mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
89623fbb99
commit
86665e788b
3 changed files with 28 additions and 17 deletions
|
|
@ -58,14 +58,24 @@ impl Cwd {
|
|||
return cache.into();
|
||||
}
|
||||
|
||||
let count = cache.strip_prefix(Xdg::cache_dir()).expect("under cache dir").components().count();
|
||||
'outer: for n in (0..count).rev() {
|
||||
let latter = cache.strip_prefix(Xdg::cache_dir()).expect("under cache dir");
|
||||
let mut it = latter.components().peekable();
|
||||
while it.peek() == Some(&C::CurDir) {
|
||||
it.next().unwrap();
|
||||
}
|
||||
|
||||
let mut count = 0;
|
||||
for c in it {
|
||||
match c {
|
||||
C::Prefix(_) | C::RootDir | C::ParentDir => return cache.into(),
|
||||
C::CurDir | C::Normal(_) => count += 1,
|
||||
}
|
||||
}
|
||||
|
||||
for n in (0..count).rev() {
|
||||
let mut it = cache.components();
|
||||
for _ in 0..n {
|
||||
match it.next_back().unwrap() {
|
||||
C::Prefix(_) | C::RootDir | C::ParentDir => break 'outer,
|
||||
C::CurDir | C::Normal(_) => {}
|
||||
}
|
||||
it.next_back().unwrap();
|
||||
}
|
||||
match std::fs::remove_file(it.as_path()) {
|
||||
Ok(_) => break,
|
||||
|
|
|
|||
|
|
@ -238,17 +238,19 @@ impl Local {
|
|||
use std::os::unix::fs::OpenOptionsExt;
|
||||
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let mut reader = std::fs::File::open(from)?;
|
||||
let mut writer = std::fs::OpenOptions::new()
|
||||
.mode(cha.mode.bits() as _)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.open(to)?;
|
||||
let mut opts = std::fs::OpenOptions::new();
|
||||
if let Some(mode) = attrs.mode {
|
||||
opts.mode(mode.bits() as _);
|
||||
}
|
||||
|
||||
let mut reader = std::fs::File::open(from)?;
|
||||
let mut writer = opts.write(true).create(true).truncate(true).open(to)?;
|
||||
let written = std::io::copy(&mut reader, &mut writer)?;
|
||||
writer.set_permissions(cha.into()).ok();
|
||||
writer.set_times(cha.into()).ok();
|
||||
|
||||
if let Some(mode) = attrs.mode {
|
||||
writer.set_permissions(mode.into()).ok();
|
||||
}
|
||||
writer.set_times(attrs.into()).ok();
|
||||
|
||||
Ok(written)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -142,8 +142,7 @@ impl Operator {
|
|||
F: ToByteStr<'a>,
|
||||
T: ToByteStr<'a>,
|
||||
{
|
||||
let req = requests::Rename::new(from, to)?;
|
||||
let status: responses::Status = self.send(req).await?;
|
||||
let status: responses::Status = self.send(requests::Rename::new(from, to)?).await?;
|
||||
status.into()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue