[PATCH] first draft of new auto-save functionality.



This is a first draft of new auto-save code, which works more like emacs
#<foo># files and less like XL's (IMO broken) model.

This code completely works.  It's not a "first draft" in that sense.
But it changes some interfaces and ties in to the current xml-io code
pretty tightly (intentionally, I might add, as I can't see any sane reason
for supporting multiple auto-save formats --- especially if it means we
might end up auto-saving to incomplete export formats or using a save
plugin which could *itself* crash, negating the whole point of using
something like auto-save).  The current code saves every N minutes --
every minute right now, as that makes it easier to test.  It contains some
comments on how to extend this so that large changes and idle time prompt
more aggressive auto-saves, and long save times decrease the autosave
frequency.

It's also a "first draft" in that I made auto-save a per-workbook (not
per-view or per-control) features.  This means that even workbooks
embedded w/in other docs or accessed via CORBA, etc, would be autosaved.
The existing XL-based auto-save code is per gui control.  This is
obviously a design point that should be discussed before I work on the
code much more; the gui-less nature also necessitates some hackery which
might perhaps indicate other more general interface changes (to the file
saver code, for example) which might be motivated.  Finally, for security
and safety, and writes to temporary files should test-existence-and-open
atomically to make sure there are no race conditions between the time you
test that another file doesn't exist and the time you attempt to open the
new file for writing.  The current file-saver interface doesn't support
this; again mild hacking necessary here that should be examined and
discussed.

So without further ado, you'll find two patch files attached.  Sorry, but
CVS won't let me cleanly diff un-added files, so "part2" of the patch
contains a diff-style addition of my two new files, auto-save.c and
auto-save.h. You can examine them for a general taste of the interface and
approach. The changes necessary to existing code to support this are
described by the (CVS-style) "part1" of the patch.  We call
auto_save_check_recover() on startup in main.c, and in
workbook.c we call auto_save_destroy() in the
workbook_finalize method, auto_save_reset() in the workbook_set_dirty()
method, and set up the auto-save fields in workbook_new().
The hackery is adding a new gnumeric_xml_write_workbook_to_fd() function
in xml-io.c (which shares most of the code from
gnumeric_xml_write_workbook()) and adding an extra parameter to
wb_view_open_custom() to return the WorkbookControl that this function
actually created.

Comments are welcome!  Please!
 --scott

Sudan Philadelphia D5 SLBM Rijndael Qaddafi ASW operative SSBN 743 
Sabana Seca Richard Tomlinson ammunition Hager TASS Moscow plastique 
              ( http://lesser-magoo.lcs.mit.edu/~cananian )

Attachment: patch-HEAD-cvs.autosave-part1
Description: CVS-style diff of existing code

Attachment: patch-HEAD-cvs.autosave-part2
Description: Standard diff of two new auto-save files



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]