Code::Blocks Forums
Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: Poobah on January 15, 2007, 05:14:52 am
-
Hi, I use a computer that completely locks up about once or twice a day, so the autosave plug-in is a life saver! As someone who frequently uses it, I have found that it would be quite helpful if the autosave plug-in detected if it wasn't terminated correctly during its last session, and if it wasn't, prompted to replace the original files that were in use with the auto-saved ones whose modification dates were more recent than those of the original files. This feature would only be necessary for people who choose to save the backups as "original file name.save"
-
One way of accomplishing this would simply be to pop up a dialog box asking if you want to open the .sav/.bak file if it's newer than the project file.
-
Are you suggesting I use some sort of scripting feature to do this? I don't even know what all that squirrel stuff is all about. :S
-
No, I was simply thinking out loud about a change that could be made to the actual source of the IDE.
-
The idea as such is good, I'll think about how it can be implemented.
-
The idea as such is good, I'll think about how it can be implemented.
I'm be interested also. Especially since the keybinder ini file can become corrupt during a crash while keybinder is doing a dynamic menu merge.
Can I ape your code?
-
Do most crashes result in the "lock file" being left behind? If so here is my solution: If CB starts up and sees the lockfile still in place then it searches for all .bak files in the project it was last using (should be the most recently project). If any of those .bak files have newer timestamps times than actuall file you know that the editor was closed while the user was still editing a file. You can then prompt the user and restore the file.
-
Does this feature (ability to autorestore or, even, manually from within C::B) implemented since 2007... I don't see it.
Also, I've noticed if you choose the option to save as original files (so, overwrite them), C::B still show the "*" beside filenames on its editor tabs. It would be smart that the autosave plugin warns C::B about external change (or do C::B considers the action of autosave as an internal save).
Third, it could be useful to have an option "save in a subdirectory" (using original filenames) : this way, external restore by hand will be just a simple copy, accepting the overwriting warning from OS. Just an idea.
-
I've completely forgotten about that feature, mostly because Code::Blocks didn't crash since approx. 2008 (which kind of makes autosave kind of superfluous) :P
Uh... time... let me see if I find time for this, maybe between christmas and new year.
-
Also, I've noticed if you choose the option to save as original files (so, overwrite them), C::B still show the "*" beside filenames on its editor tabs. It would be smart that the autosave plugin warns C::B about external change (or do C::B considers the action of autosave as an internal save).
But it does just this, save the original file and the state of the file is set to not modified and the '*' is removed. I use this feature every day and I know it works.
-
Some programs do crash recovery/auto restore in the following method:
- Periodically save a copy of modified files (plus meta-data pointing to the location of the actual file) to a directory in the application data folder
- When a file/project is saved (in Code::Blocks), delete the corresponding shadow copy (if it exists)
- When a file/project is closed (in Code::Blocks), delete the corresponding shadow copy (if it exists)
- On startup, check the recovery directory in the application data folder, if any files exist in it, prompt the user (for each file) to:
- restore - shadow copy is written over the actual file, then shadow copy is deleted
- discard - shadow copy is deleted
- remind me later - nothing is done (the shadow copy still exists, so it will prompt on next startup)
This is different in that it can be done silently/invisibly, without the user ever seeing the extra files. Maybe this would be an advantage, or maybe not; but it is another idea you could consider.
-
Alpha: Why bother doing reimplementing the wheel, when there is git :) (which does the same) or any backup solution native to your OS?
-
I guess I forgot to mention (but I thought it was assumed?) this is for crash protection: the shadow copies would only exist on startup if Code::Blocks unexpectedly quit/crashed on the last run.
Maybe "shadow copy" was not the best choice of words. It is not a backup of a file, but a snapshot of unsaved data. So I do not believe this is a reimplementation of the wheel (as Code::Blocks does not currently have an "auto-restore from crash recovery files wheel" :)), just a different design option for the above discussed auto-restore feature.