Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

Merge pull request #868 from Ruchir317/pr-864

Özer Güzel8c27d16af5fa
diff --cc crates/rf-win/src/fastcopy.rs
index feba7c8a,ff7499a4..41dbe892
--- a/crates/rf-win/src/fastcopy.rs
+++ b/crates/rf-win/src/fastcopy.rs
@@@ -751,24 -752,25 +752,38 @@@ fn run_jobs(mut p: Plan, tracker: &Trac
.into_iter()
.filter_map(|i| jobs[i].dst.parent().map(|d| (jobs[i].src.clone(), d.to_path_buf())))
.collect();
+ let done_indices = done.into_inner().unwrap();
+ let done_pairs: HashSet<(&Path, &Path)> = done_indices.iter().map(|&i| (jobs[i].src.as_path(), jobs[i].dst.as_path())).collect();
+ let job_pairs: HashSet<(&Path, &Path)> = jobs.iter().map(|j| (j.src.as_path(), j.dst.as_path())).collect();
+ let undo: Vec<(PathBuf, PathBuf)> = p
+ .undo
+ .into_iter()
+ .filter(|(s, d)| {
+ if job_pairs.contains(&(s.as_path(), d.as_path())) {
+ done_pairs.contains(&(s.as_path(), d.as_path()))
+ } else {
+ !cancelled || done_indices.iter().any(|&i| jobs[i].dst.starts_with(d))
+ }
+ })
+ .collect();
let mut copied = already;
- copied.extend(done.into_inner().unwrap().into_iter().filter(|&i| jobs[i].op == Op::Copy).map(|i| (jobs[i].src.clone(), jobs[i].dst.clone())));
- Outcome { undo: p.undo, failed, whole: p.whole, copied, src_dirs: p.src_dirs, cancelled }
+ copied.extend(done_indices.into_iter().filter(|&i| jobs[i].op == Op::Copy).map(|i| (jobs[i].src.clone(), jobs[i].dst.clone())));
+ Outcome { undo, failed, whole: p.whole, copied, src_dirs: p.src_dirs, cancelled }
}
+/// Tells the shell once about each folder a transfer changed: the sources' folders, then the destination. Once per folder, not per
+/// item: every call costs the shell a look at the folder, about 9 ms in one of 50,000 files, which made the notes of a 2,000-file move
+/// take 18 s.
+fn notify_folders<'a>(parents: impl Iterator<Item = &'a Path>, dest_dir: &Path) {
+ let mut seen: HashSet<&Path> = HashSet::new();
+ for p in parents {
+ if p != dest_dir && seen.insert(p) {
+ crate::shell::notify_updated(p);
+ }
+ }
+ crate::shell::notify_updated(dest_dir);
+}
+
/// Copies `sources` into `dest_dir` in parallel (conflicts as `tracker.ask` says; without it
/// both are kept). Returns the undo pairs and the leftovers for the shell.
pub fn copy(sources: &[PathBuf], dest_dir: &Path, tracker: &Tracker, threads: usize) -> Outcome {