Use copy instead of move when pasting to different device, fixes #337
This commit is contained in:
parent
d0359af0b5
commit
136b1e6c37
1 changed files with 28 additions and 4 deletions
32
src/app.rs
32
src/app.rs
|
|
@ -1950,10 +1950,34 @@ impl Application for App {
|
|||
});
|
||||
}
|
||||
ClipboardKind::Cut => {
|
||||
self.operation(Operation::Move {
|
||||
paths: contents.paths,
|
||||
to,
|
||||
});
|
||||
//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,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue