mmi: fix race condition for restoring the original file from the .tmp file