At application shutdown I want to send a file to a server via Internet (with Indy). If data is sent ok, I want to delete that file from the computer. The critical part is that my file should NOT be stored in both places (server, local computer) at the same time.
For example, my application may unexpectedly stop AFTER it sent the file to the server and BEFORE it deleted the file from local disk. In this case the file will exist in both places.
The application may stop because of the following reasons: power failure, Control+Alt+Del, shutdown by OS, shutdown by user, system hang (maybe there are other reasons that I forgot?).
How can I guarantee that the file is stored in one single place?
I think we can consider that writing the file to disk is instantaneous since the file is very small.
This is how I (partially) solved my problem
The problem is that between step 1 and 2 the file exists nowhere. If the app dies at that point, the file is lost (however, this is a bit more acceptable than being in two places). Unfortunately the delay between step 1 and step 2 is HUGE since communication with the remote server is extremely slow (maybe even up to 1-2 seconds).