fixed: mv winix function didn't move a file correctly

- if a file was moved (renamed) into the same directory and a file with the new name
already existed then nothing was done (now a message is shown that such a file already exists)
- if a file was moved to another directory and there was a file wich such a name there
then the moved file had its original name (now a message is shown that such a file already exists)
This commit is contained in:
Tomasz Sowa 2021-01-27 17:30:55 +01:00
parent a69e160f85
commit a9b9d0badf
1 changed files with 9 additions and 5 deletions

View File

@ -584,12 +584,16 @@ bool Mv::MoveFileOrSymlink2(Item & src_file, const std::wstring & dst_path, bool
if( !ParseDir(dst_path, check_access) )
return false;
if( src_file.parent_id == out_dir_tab.back()->id )
if( out_has_file && src_file.parent_id == out_dir_tab.back()->id && src_file.url == out_item.url )
{
// actually out_filename is here empty
// because ParseDir() have been read it to out_item
if( out_filename.empty() || src_file.url == out_filename )
return true; // the same file -- there is nothing to do
return true; // the same file -- there is nothing to do
}
if( out_has_file )
{
log << log3 << "Mv: such file already exists (skipping)" << logend;
slog << logerror << T("mv_file_exists") << logend;
return false;
}
return MoveFileOrSymlink(src_file, out_dir_tab, out_filename);