Re: Saving layout files #HowTo #Bug


Adam Richards
 

Hi Mike, 
Let's walk the scenario out and see what can happen - and also work out if we have a bug. <shock!, horror!>

Seriously - there has been a bug recently found and fixed in this area - fix #3788 - where when you Save As or Open a new layout filename the current checkpoint was not wiped out, so that if you don't make enough changes to trigger another checkpoint but quit/fail AND when you restart you ask for the checkpoint to be used, the layout will have the new name BUT the contents will be the old layout file. A quick Save at that point, and the "new" layout file is toast, overwritten by the old file checkpoint!!!  No Bueno!

- How is it supposed to work? 

At any one time XTrackCAD is working with one filename.  When you Save As... you are writing out a new file with all the changes up to current with a different name and you are changing the current filename it is using.  Open also changes the name. So that's item 1. Save As is abandoning the old current (whatever state it was) and making a new file current.

Now if you had Saved the current layout just before at that point - both the current layout file and the Save As... layout file will be identical.  And that could happen in a couple of ways -

  1. You could have just Saved and immediately Exit the program - when you exit, you'll get asked if you want to save including all current changes but if there are none, or you say no.... two identical files.  This is the scenario in the area of the bug, of course, because on restart the checkpoint from the old file is lurking ready to pounce.
  2. New changes do not make it into the current layout file immediately - every so many changes they pile up in the checkpoint files and will be available when you restart the program, but if you do enough of them (i.e., take enough checkpoints), Auto-Save (assuming it is set on) will update the current file for you.  So, it could be that you had exactly enough changes to auto-save just before the point at which you did Save As... because the very last change you did was at the auto-save mark and it had saved, so your Save As... created an identical file. 
So, in summary, I imagine the issue may be auto-save was not included in your calculation because it was operating on its own time-scale. You could always turn it off Options->Preferences->Autosave Checkpoint Frequency=0 if you want total control of saving.  

- Emergency Escape Hatch 

There is a sneaky way to rollback changes if enough time has not past (enough changes haven't been made to the same file) as long as Options->Preferences->Checkpoint Frequency is non 0. Every checkpoint is a full layout save and there is a rotating set of prior ones that get saved to when the new one gets written. They live in the working directory and have names like your_layout_name.xtc_xx.bkp and five are kept (xx=01 to 05). You will need to look at the timestamp to know which is newest to oldest as the numbers wrap around. To recover any particular one, copy/move it to your own directory and rename it to your_recovered_layout_ name.xtc. Then Open it. The file "xtrkcad.rc" is always the last/current checkpoint file and is newer than the .bkp ones and a similar rename trick works on it. 

--------------- 

Auto_Save is new to V5.2.  We previously had checkpoint (with only one checkpoint) intended to try and cope with failures, but folks were not Saving for extended periods and so ending up losing work. They had an expectation that the program was like Word or Google and would "take care of that".  I'm not sure we are quite all the way there because of the issue that you illustrate that a different mental model is the one where the user wants to use save prior versions of the layout as backups but they would prefer to have the same layout filename as current rather than swapping it and be able to rollback by selecting old versions. It may be that we should support a way of auto-copying the saves out as explicit versions with timestamps so that whether the layout is manually saved or auto-saved there is a version copy preserved for as long as the user wants. Then we could support opening prior versions in some way to rollback changes to that point.  Anyone with thoughts on this area would be helpful. 

Adam

 

Join main@xtrackcad.groups.io to automatically receive all group messages.