fix an issue that copying directory will fail when trying to change file attributes and the target file already exists on remote

- the issue was introduced by the commit 84759faa0950146a6bae8452580b4a4cede6d871
Merge pull request #8271 from tksmd/fix-copy-set-fs-attributes-issue

fix an issue that copying directory will fail when trying to change file attributes