What is the benefit of writing to a temp location, And then copying it to the intended destination?

Posted by Devdatta Tengshe on Programmers See other posts from Programmers or by Devdatta Tengshe
Published on 2012-06-16T14:48:23Z Indexed on 2012/06/16 15:22 UTC
Read the original article Hit count: 250

Filed under:

I am writing an application that works with satellite Images, and my boss asked me to look at some of the commercial application, and see how they behave. I found a strange behavior and then as I was looking, I found it in other standard applications as well.

These Programs first write to the temp folder, and then copy it to the intended destination.

Example: 7zip first extracts to the temp folder, and then copies the extracted data to the location that you had asked it to extract the data to.

I see several problems with this approach:

1.The temp folder might not have enough space, while the intended location might have that much space.

2.If it is a large file, it can take a non-negligible amount of time for the copy operation.

I thought about it a lot, but I couldn't see one single positive point to doing this. Am I missing something, or is there a real benefit to doing this?

© Programmers or respective owner

Related posts about explanation