If you don't have to 'touch' the file until it hasn't been completed, then an approach could be to ask the remote server also to put the MD5 sum of the file *ONLY* after the transfer is completed.
Let's suppose the file is called 'file' and the md5 sum is 'file.md5'
if [ -x file.md5 ]
--> first check if the sum is correct,
--> then perform the other operations