My program is downloading data from a server, once he received all the data, my program handles the data (performs checks like if that data is still on the server) and saves it into my database.
Now I was wondering what if my internet connection suddenly is disconnected, what happens with the data that I just was receiving. So I did a test. When I break the internet connection, my program stops fetching the data and goes to my method to check the data.
Now this wrong, because he will set some data already in my database that it isn't any more on the server, when it actually is.
The server is accessed by an API (webservices).
So my question is what is a good way to handle this kind of situation?