forked from extern/nushell
Fix mv data loss when changing folder case (step 1) (#6599)
* Fix mv data loss when changing folder case (step 1) * Use same-file to detect when changing case on Windows
This commit is contained in:
@ -253,8 +253,12 @@ fn move_file(
|
||||
return Err(ShellError::DirectoryNotFound(to_span, None));
|
||||
}
|
||||
|
||||
// This can happen when changing case on a case-insensitive filesystem (ex: changing foo to Foo on Windows)
|
||||
// When it does, we want to do a plain rename instead of moving `from` into `to`
|
||||
let from_to_are_same_file = same_file::is_same_file(&from, &to).unwrap_or(false);
|
||||
|
||||
let mut to = to;
|
||||
if to.is_dir() {
|
||||
if !from_to_are_same_file && to.is_dir() {
|
||||
let from_file_name = match from.file_name() {
|
||||
Some(name) => name,
|
||||
None => return Err(ShellError::DirectoryNotFound(to_span, None)),
|
||||
|
Reference in New Issue
Block a user