Issue#935

Incoming Jenkins testrun:
https://jenkins.catrob.at/view/All-Categories/view/Catroid-multi-job/job/Catroid-Multi-Job-Custom-Branch/1937/

Process How Files are getting saved (in order to avoid data loss):
You have 3 steps. During/Before/After the first 2 steps (The renaming should be atomic on Linux/Android) an error can occur, this will be checked within the SanityCheckFunction().

-- Filestate: code.xml
1. Write to tmp_code.xml            
-- Filestate: code.xml tmp_code.xml   
2. Delete code.xml
-- Filestate: tmp_code.xml   
3. (usually atomic) rename tmp_code.xml    --> code.xml
-- Filestate: code.xml

To make things clearer:
SanityCheckFunction only needs to verify 2 states.

Either tmp_code.xml AND code.xml exist:
-Then it has to delete tmp_code.xml as this state only occurs during/after step 1 and before step 2.
Or only tmp_code.xml exists
-then it has to rename tmp_code.xml to code.xml. This state can only occur after step 2 but before step 3.

@aried3r