only ask if there are actually contents in the file. Asking about an

2001-07-06  Larry Ewing  <lewing@ximian.com>

	* e-msg-composer.c (autosave_manager_query_load_orphans): only ask
	if there are actually contents in the file.  Asking about an
	emptry fil is not very useful.
	(autosave_load_draft): add some sanity chacks.
	(autosave_run_foreach_cb): remove debugging warning.

svn path=/trunk/; revision=10863
This commit is contained in:
Larry Ewing
2001-07-06 21:44:15 +00:00
committed by Larry Ewing
parent 53e8e2ec8d
commit a8fbf376d8
2 changed files with 33 additions and 13 deletions

View File

@ -1,3 +1,11 @@
2001-07-06 Larry Ewing <lewing@ximian.com>
* e-msg-composer.c (autosave_manager_query_load_orphans): only ask
if there are actually contents in the file. Asking about an
emptry fil is not very useful.
(autosave_load_draft): add some sanity chacks.
(autosave_run_foreach_cb): remove debugging warning.
2001-07-06 Larry Ewing <lewing@ximian.com>
* e-msg-composer.c (autosave_manager_unregister): make sure we

View File

@ -1084,8 +1084,15 @@ autosave_load_draft (const char *filename)
CamelMimeMessage *msg;
EMsgComposer *composer;
g_return_val_if_fail (filename != NULL, NULL);
g_warning ("autosave load filename = \"%s\"", filename);
stream = camel_stream_fs_new_with_name (filename, O_RDONLY, 0);
if (stream == NULL)
return NULL;
msg = camel_mime_message_new ();
camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream);
unlink (filename);
@ -1128,33 +1135,38 @@ autosave_manager_query_load_orphans (AutosaveManager *am, EMsgComposer *composer
struct dirent *d;
GSList *match = NULL;
gint len = strlen (AUTOSAVE_SEED);
gint pre_len;
gint ok;
/* length of the seed minus the XXXXXX */
pre_len = len - 6;
dir = opendir (g_get_home_dir());
if (!dir) {
return;
}
while ((d = readdir (dir))) {
if ((!strncmp (d->d_name, AUTOSAVE_SEED, pre_len) )
if ((!strncmp (d->d_name, AUTOSAVE_SEED, len - 6))
&& (strlen (d->d_name) == len)
&& (!autosave_is_owned (am, d->d_name))) {
char *filename = g_strdup_printf ("%s/%s", g_get_home_dir(), d->d_name);
struct stat st;
/*
* check if the file has any length, It is a valid case if it doesn't
* so we simply don't ask then.
*/
if (stat (filename, &st) < 0 || st.st_size == 0)
continue;
dialog = gnome_ok_cancel_dialog_parented (_("Evolution has detected an editor buffer from a previous session.\n"
"Would you like to recover this buffer?"),
autosave_query_cb, &ok, GTK_WINDOW (composer));
gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
if (ok) {
match = g_slist_prepend (match,
g_strdup_printf ("%s/%s",
g_get_home_dir(),
d->d_name));
}
if (ok)
match = g_slist_prepend (match, filename);
else
g_free (filename);
}
}
@ -1164,7 +1176,7 @@ autosave_manager_query_load_orphans (AutosaveManager *am, EMsgComposer *composer
EMsgComposer *composer;
composer = autosave_load_draft (filename);
g_free (filename);
g_slist_free_1 (match);
match = next;
@ -1175,7 +1187,7 @@ static void
autosave_run_foreach_cb (gpointer key, gpointer value, gpointer data)
{
EMsgComposer *composer = E_MSG_COMPOSER (value);
g_warning ("autosave");
autosave_save_draft (composer);
}