But no. The auto-save file was AWOL.
Investigating, I stumbled upon the irony: the auto-save itself had failed, resulting in the crash. So I lost 25 minutes of work. Annoyed, I had a closer look at the coding around the auto-save. In meta language, this was:
- Run auto-save after x minutes;
- If a current auto-save file exists, delete it;
- Save to the vacant auto-save file slot;
- Return.
This was lazy programming on my part. Yes, the save shouldn't have failed. However, it did, and I didn't deal with it. Enter transaction coding. The new meta code is now:
- Run auto-save after x minutes;
- If a current auto-save file exists, move it to designated temp directory;
- Save to the vacant auto-save file slot - but catch any errors this produces;
- In the event of any error, and a previous auto-save exists, make a note, and move the file back;
- In the event of any error, and no previous auto-save exists, make a note, and try again in a minute;
- In the event of no error, delete the previous auto-save file from the temp directory;
- Return.
No comments:
Post a Comment