Code::Blocks

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: Poobah on January 15, 2007, 05:14:52 am

Title: "Auto restore" feature for autosave plug-in?
Post 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"
Title: Re: "Auto restore" feature for autosave plug-in?
Post by: Revvy on January 15, 2007, 06:20:36 pm
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.
Title: Re: "Auto restore" feature for autosave plug-in?
Post by: Poobah on January 16, 2007, 03:03:44 am
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
Title: Re: "Auto restore" feature for autosave plug-in?
Post by: Revvy on January 17, 2007, 02:30:02 am
No, I was simply thinking out loud about a change that could be made to the actual source of the IDE.
Title: Re: "Auto restore" feature for autosave plug-in?
Post by: thomas on January 17, 2007, 01:23:12 pm
The idea as such is good, I'll think about how it can be implemented.
Title: Re: "Auto restore" feature for autosave plug-in?
Post by: Pecan on January 17, 2007, 02:38:55 pm
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?

 
Title: Re: "Auto restore" feature for autosave plug-in?
Post by: Game_Ender on January 19, 2007, 11:09:00 pm
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.
Title: Re: "Auto restore" feature for autosave plug-in?
Post by: eranon on August 30, 2012, 12:13:31 am
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.
Title: Re: "Auto restore" feature for autosave plug-in?
Post by: thomas on November 13, 2012, 03:46:26 pm
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.
Title: Re: "Auto restore" feature for autosave plug-in?
Post by: oBFusCATed on November 13, 2012, 04:25:51 pm
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.
Title: Re: "Auto restore" feature for autosave plug-in?
Post by: Alpha on November 14, 2012, 11:48:31 pm
Some programs do crash recovery/auto restore in the following method:

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.
Title: Re: "Auto restore" feature for autosave plug-in?
Post by: oBFusCATed on November 15, 2012, 12:08:56 am
Alpha: Why bother doing reimplementing the wheel, when there is git :) (which does the same) or any backup solution native to your OS?
Title: Re: "Auto restore" feature for autosave plug-in?
Post by: Alpha on November 15, 2012, 12:23:57 am
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.