Auto-save mechanism
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Auto-save mechanism
There is now an auto-save and a recovery tool implemented in FreeCAD.
How it works:
1. When a FreeCAD instance gets started it creates a lock file FreeCAD_PID.lock (e.g. FreeCAD_1276.lock) and for each created document a transient directory is created of the form FreeCAD_Doc_HASH_PID (e.g.FreeCAD_Doc_afda3e1d-482d-4fb2-b313-8dc45672d7b3_da39a3_1276)
2. For each created document after a certain time there is a project file stored called 'fc_recovery_file.fcstd' inside the document's transient directory.
Inside this directory there is a second file created called 'fc_recovery_file.xml' which contains some meta-information about the fcstd file which cannot be stored directly there.
3. When FreeCAD crashes then the lock file and the transient directory won't be deleted.
4. When FreeCAD starts the next time it searches for .lock with a different process ID and then searches for transient directories with these process IDs. Afterwards it checks if inside the found directories there is the file 'fc_recovery_file.fcstd'. Additionally, it checks for the 'fc_recovery_file.xml' and reads the status flag. If this file doesn't exist or if the flag is set to 'Created' then the .fcstd file is marked for recovery.
5. Now a dialog comes up with all .fcstd files marked for recovery. The user has to press the 'Start Recovery' button and must wait until the procedure has finished. The dialog shows which project files could be recovered and which not. At this time the xml files are re-written with the status set to 'Success' or 'Failure' to avoid to try to recover the files the next time FreeCAD starts.
NOTE: The recovery files won't be deleted.
Parameters for the auto.save option and recovery tool are inside the group 'Document':
* RecoveryEnabled: a boolean to enable or disable the recovery tool
* AutoSaveEnabled: a boolean to enable or disable the auto-saving
* AutoSaveTimeout: an integer to set the timeout when the recovery files should be created. The default value is 15, i.e. 15 min. Possible values are in the range 1-60 min.
How it works:
1. When a FreeCAD instance gets started it creates a lock file FreeCAD_PID.lock (e.g. FreeCAD_1276.lock) and for each created document a transient directory is created of the form FreeCAD_Doc_HASH_PID (e.g.FreeCAD_Doc_afda3e1d-482d-4fb2-b313-8dc45672d7b3_da39a3_1276)
2. For each created document after a certain time there is a project file stored called 'fc_recovery_file.fcstd' inside the document's transient directory.
Inside this directory there is a second file created called 'fc_recovery_file.xml' which contains some meta-information about the fcstd file which cannot be stored directly there.
3. When FreeCAD crashes then the lock file and the transient directory won't be deleted.
4. When FreeCAD starts the next time it searches for .lock with a different process ID and then searches for transient directories with these process IDs. Afterwards it checks if inside the found directories there is the file 'fc_recovery_file.fcstd'. Additionally, it checks for the 'fc_recovery_file.xml' and reads the status flag. If this file doesn't exist or if the flag is set to 'Created' then the .fcstd file is marked for recovery.
5. Now a dialog comes up with all .fcstd files marked for recovery. The user has to press the 'Start Recovery' button and must wait until the procedure has finished. The dialog shows which project files could be recovered and which not. At this time the xml files are re-written with the status set to 'Success' or 'Failure' to avoid to try to recover the files the next time FreeCAD starts.
NOTE: The recovery files won't be deleted.
Parameters for the auto.save option and recovery tool are inside the group 'Document':
* RecoveryEnabled: a boolean to enable or disable the recovery tool
* AutoSaveEnabled: a boolean to enable or disable the auto-saving
* AutoSaveTimeout: an integer to set the timeout when the recovery files should be created. The default value is 15, i.e. 15 min. Possible values are in the range 1-60 min.
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Auto-save mechanism
Sounds awesome!
Re: Auto-save mechanism
This is a godsend. Thank you very much.
Need help? Feel free to ask, but please read the guidelines first
-
- Posts: 436
- Joined: Wed Sep 15, 2010 9:38 am
Re: Auto-save mechanism
FreeCAD just crashed so I had the opportunity to test the auto-save mechanism.
It worked pretty well, thanks Werner for it !
There is something I'm not sure about but I don't know how to provoke a crash to test it:
Do saved files also go through the recovery process?
I had the impression they do. I had untouched files opened and when the recovery process went through, these files were opened and had the 'modified' status.
It worked pretty well, thanks Werner for it !
There is something I'm not sure about but I don't know how to provoke a crash to test it:
Do saved files also go through the recovery process?
I had the impression they do. I had untouched files opened and when the recovery process went through, these files were opened and had the 'modified' status.
Re: Auto-save mechanism
Simply open a terminal window and enterThere is something I'm not sure about but I don't know how to provoke a crash to test it:
Code: Select all
killall FreeCAD
It depends. If the time stamp of the saved regular project file is newer than of the recovery file then it doesn't go through the recovery process because you have no gain of information if you restored it. In the output window you should get a warning that the recovery file is ignored.Do saved files also go through the recovery process?
If the time stamp of the recovery file is newer then it goes normally through the recovery process.
All recovered documents have the 'modified' status because otherwise if you have stored your document before the crash you could close it without being asked to save it. Then you would lose the recovered information.I had the impression they do. I had untouched files opened and when the recovery process went through, these files were opened and had the 'modified' status.
However, the recovery function does NOT delete any data. All what it does is opening the file fc_recovery_file.xml and changes the status from 'Created' to something else (to 'Success' when it could be restored, 'Failure' if it failed, 'Deprecated' if the saved project is newer and 'Unknown' in all other cases).
So, if you want to re-process the recovery you have to open the fc_recovery_file.xml file and manually change the status back to 'Created'. But be careful: this way the xml file gets a newer time stamp and you have to check if the saved project file is what you actually want to keep.
Re: Auto-save mechanism
If anyone out there wants to do this graphically on Kubuntu and presumably other KDE distros, you can do so by running the "system monitor", right click on FreeCAD (if it is running) and then "send signal" "Kill"wmayer wrote:Simply open a terminal window and enter
Code: Select all
killall FreeCAD
On Windows kill it with the task manager.
Its under K menu, applications, system, system monitor, ...process table tab...
Re: Auto-save mechanism
There is also a keyboard shortcut ( Kubuntu also ) :If anyone out there wants to do this graphically on Kubuntu and presumably other KDE distros, you can do so by running the "system monitor", right click on FreeCAD (if it is running) and then "send signal" "Kill"
Its under K menu, applications, system, system monitor, ...process table tab...
- CTRL + ALT + Escape
- the mouse pointer change to a red "pirate skull" ( not sure it is the right word )
- Left clic the window to kill, or right clic to abort killing operation
Re: Auto-save mechanism
I think it would be good if there would be a way in the gui to (1) skip / ignore the recovery so that the dialog window would not show up on every FC start if there are files that can be recovered and (2) remove the files from the recovery dialog and temp folder, ex. select the file in the dialog, left mouse click, remove... (some very bad things can start to happen on Windows in the temp folder gets to big, been there ).
Re: Auto-save mechanism
Did you check the preferences? There is an option to switch off the auto-recovery and there is an option to switch off the auto-save.(1) skip / ignore the recovery so that the dialog window would not show up
I also thought about adding this possibility.(2) remove the files from the recovery dialog and temp folder