fetchindex: do not leave a corrupted INDEX
When extracting the fetched index, do it in a temporary file, and only
when extraction succeed, move it to the final file, it makes it more
atomic and less likely to live a corrupted file behind
PR: 224871