Copy host: a renamed file has its old name after a copy host
I ran into a strange issue that possibly also explains issue #4894. After a copy host I noticed that some files could not be found. When comparing the 2 hosts using WEBDAV and Beyond Compare there were no differences, but in the Site Browser I noticed that the files had different names. When opening a file, the filename was the one it should be but the Site Browser showed the wrong (old) one. Save/publishing the file solved the issue.
When checking the file again the History tab showed both the old filename and the new filename multiple times. I think something goes wrong with this. Unfortunately I can't reproduce this at the moment since someone changed the admin password on the demo website. I'll try to do this as soon as possible.
I was able to reproduce this on the demo website (shared), after 2 tries: First try (didn't reproduce):
- Rename the file /vtl/widgets/full-site/account-confirmation.vtl to /vtl/widgets/full-site/account-confirmation-renamed.vtl
- Copy host shared
- Check the file in the site browser, it is named account-confirmation-renamed.vtl
Second try (this reproduced the issue):
- Upload a new version of the /vtl/widgets/full-site/account-confirmation.vtl with a small change (3 times)
- Rename the /vtl/widgets/full-site/account-confirmation.vtl to /vtl/widgets/full-site/account-confirmation-renamed.vtl
- Upload a new version of the file /vtl/widgets/full-site/account-confirmation-renamed.vtl with a small change
- Copy host shared
- Check the file. In the site browser it is named account-confirmation.vtl but in WEBDAV or when editing it is named account-confirmation-renamed.vtl. After a save/publish it is ok again.
I have some screenshots:

it turns out contentletAPI.copyContentlet moves all the versions of the content/fileasset. so it should save older versions first and make sure the working version is the last to be saved. There was the bug
Fixed, Tested on Nightly Build 2014-04-01