Handle errors on rename of target file.
Handle errors on rename of target file.

[apenwarr: this is the remaining part after part of the original was
included in someone else's separate patch.]

apenwarr/redo,apenwarr/redo,apenwarr/redo,apenwarr/redo