Let recursive copy or move determine what to do when crossing devices
This commit is contained in:
parent
fa50b8c0f0
commit
dacd37939e
1 changed files with 4 additions and 28 deletions
32
src/app.rs
32
src/app.rs
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue