[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: CVS update: f_basic.nw
User: cnieves
Date: 05/11/18 15:31:49
Modified: . f_basic.nw s_page.nw
Log:
Changed autosave code so the timer callback doesn't do the
autosave backups. Now are made within o_undo_savestate, so
backups will ONLY be saved when there was a change to the
schematic and there was a timeout of the autosave timer.
Revision Changes Path
1.17 +1 -0 eda/geda/devel/libgeda/noweb/f_basic.nw
(In the diff below, changes in quantity of whitespace are not shown.)
Index: f_basic.nw
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/libgeda/noweb/f_basic.nw,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- f_basic.nw 28 Oct 2005 22:26:33 -0000 1.16
+++ f_basic.nw 18 Nov 2005 20:31:49 -0000 1.17
@@ -297,6 +297,7 @@
/* Reset the last saved timer */
g_get_current_time (&w_current->page_current->last_load_or_save_time);
w_current->page_current->ops_since_last_backup = 0;
+ w_current->page_current->do_autosave_backup = 0;
/* Restore permissions. */
chmod (real_filename, st.st_mode);
1.15 +5 -71 eda/geda/devel/libgeda/noweb/s_page.nw
(In the diff below, changes in quantity of whitespace are not shown.)
Index: s_page.nw
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/libgeda/noweb/s_page.nw,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- s_page.nw 28 Oct 2005 22:26:33 -0000 1.14
+++ s_page.nw 18 Nov 2005 20:31:49 -0000 1.15
@@ -185,6 +185,7 @@
g_get_current_time (&page->last_load_or_save_time);
page->ops_since_last_backup = 0;
page->saved_since_first_loaded = 0;
+ page->do_autosave_backup = 0;
/* now append page to page list of toplevel */
toplevel->page_tail->next = page;
@@ -616,7 +617,7 @@
@defun s_page_autosave w_current
It is a callback of the glib g_timeout functions.
-It is called every "interval" miliseconds and it saves a backup copy of the opened pages.
+It is called every "interval" miliseconds and it sets a flag to save a backup copy of the opened pages.
The argument is the toplevel structure.
@end defun
@@ -624,86 +625,19 @@
gint
s_page_autosave (TOPLEVEL *toplevel)
{
- PAGE *p_save, *p_current;
- gchar *backup_filename;
- gchar *real_filename;
- gchar *only_filename;
- gchar *dirname;
- mode_t saved_umask;
- struct stat st;
-
- g_assert (toplevel->page_head != NULL &&
- toplevel->page_head->pid == -1);
-
- /* save current page */
- p_save = toplevel->page_current;
+ PAGE *p_current;
for (p_current = toplevel->page_head->next;
p_current != NULL;
p_current = p_current->next) {
if (p_current->ops_since_last_backup != 0) {
- /* make p_current the current page of toplevel */
- s_page_goto (toplevel, p_current);
-
- /* Get the real filename and file permissions */
- real_filename = follow_symlinks (p_current->page_filename, NULL);
-
- if (real_filename == NULL) {
- s_log_message ("s_page_autosave: Can't get the real filename of %s.", p_current->page_filename);
- fprintf (stderr, "s_page_autosave: Can't get the real filename of %s.\n", p_current->page_filename);
+ /* Real autosave is done in o_undo_savestate */
+ p_current->do_autosave_backup = 1;
}
- else {
- /* Get the directory in which the real filename lives */
- dirname = g_path_get_dirname (real_filename);
- only_filename = g_path_get_basename(real_filename);
-
- backup_filename = g_strdup_printf("%s%c#%s#", dirname,
- G_DIR_SEPARATOR, only_filename);
-
- /* If there is not an existing file with that name, compute the
- * permissions and uid/gid that we will use for the newly-created file.
- */
-
- if (stat (real_filename, &st) != 0)
- {
- struct stat dir_st;
- int result;
-
- /* Use default permissions */
- saved_umask = umask(0);
- st.st_mode = 0666 & ~saved_umask;
- umask(saved_umask);
- st.st_uid = getuid ();
-
- result = stat (dirname, &dir_st);
-
- if (result == 0 && (dir_st.st_mode & S_ISGID))
- st.st_gid = dir_st.st_gid;
- else
- st.st_gid = getgid ();
}
- g_free (dirname);
- g_free (only_filename);
- g_free (real_filename);
-
- if (o_save (toplevel, backup_filename)) {
- p_current->ops_since_last_backup = 0;
- } else {
- s_log_message ("Could NOT save backup file [%s]\n",
- backup_filename);
- }
- g_free (backup_filename);
- }
- }
-
- }
-
- /* restore current page */
- s_page_goto (toplevel, p_save);
- /* Returns non-zero if we want to continue autosaving */
return toplevel->auto_save_interval;
}