Let recursive copy or move determine what to do when crossing devices

This commit is contained in:
Jeremy Soller 2024-11-13 14:47:58 -07:00
parent fa50b8c0f0
commit dacd37939e

View file

@ -2305,34 +2305,10 @@ impl Application for App {
});
}
ClipboardKind::Cut => {
//TODO: determine ability to move on non-Unix systems
let mut can_move = true;
#[cfg(unix)]
{
use std::os::unix::fs::MetadataExt;
//TODO: better error handling, fall back to not moving?
if let Ok(to_meta) = fs::metadata(&to) {
for path in contents.paths.iter() {
if let Ok(meta) = fs::metadata(path) {
if meta.dev() != to_meta.dev() {
can_move = false;
}
}
}
}
}
if can_move {
self.operation(Operation::Move {
paths: contents.paths,
to,
});
} else {
self.operation(Operation::Copy {
paths: contents.paths,
to,
});
}
self.operation(Operation::Move {
paths: contents.paths,
to,
});
}
}
}