From a9b9d0badf570bff67bbe39f042e482b7574bfe7 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Wed, 27 Jan 2021 17:30:55 +0100 Subject: [PATCH] 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) --- winixd/functions/mv.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/winixd/functions/mv.cpp b/winixd/functions/mv.cpp index 960129b..1ab030b 100644 --- a/winixd/functions/mv.cpp +++ b/winixd/functions/mv.cpp @@ -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);