mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
778758f616
commit
4267d24f06
1 changed files with 4 additions and 8 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
use std::{collections::VecDeque, fs::Metadata, path::{Path, PathBuf}};
|
use std::{collections::VecDeque, fs::Metadata, path::{Path, PathBuf}};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use filetime::{set_file_times, FileTime};
|
use filetime::{set_file_mtime, set_file_times, FileTime};
|
||||||
use tokio::{fs, io, select, sync::{mpsc, oneshot}, time};
|
use tokio::{fs, io, select, sync::{mpsc, oneshot}, time};
|
||||||
|
|
||||||
pub async fn accessible(path: &Path) -> bool {
|
pub async fn accessible(path: &Path) -> bool {
|
||||||
|
|
@ -44,17 +44,13 @@ pub fn copy_with_progress(
|
||||||
let (tick_tx, mut tick_rx) = oneshot::channel();
|
let (tick_tx, mut tick_rx) = oneshot::channel();
|
||||||
|
|
||||||
tokio::spawn({
|
tokio::spawn({
|
||||||
let (from, to, meta) = (from.to_owned(), to.to_owned(), meta.clone());
|
let (from, to) = (from.to_owned(), to.to_owned());
|
||||||
|
let mtime = FileTime::from_last_modification_time(meta);
|
||||||
|
|
||||||
async move {
|
async move {
|
||||||
_ = match fs::copy(&from, &to).await {
|
_ = match fs::copy(&from, &to).await {
|
||||||
Ok(len) => {
|
Ok(len) => {
|
||||||
_ = set_file_times(
|
set_file_mtime(to, mtime).ok();
|
||||||
to,
|
|
||||||
FileTime::from_last_access_time(&meta),
|
|
||||||
FileTime::from_last_modification_time(&meta),
|
|
||||||
);
|
|
||||||
|
|
||||||
tick_tx.send(Ok(len))
|
tick_tx.send(Ok(len))
|
||||||
}
|
}
|
||||||
Err(e) => tick_tx.send(Err(e)),
|
Err(e) => tick_tx.send(Err(e)),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue