aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog12
-rw-r--r--camel/providers/local/camel-maildir-folder.c84
-rw-r--r--camel/providers/local/camel-mbox-folder.c13
-rw-r--r--camel/providers/local/camel-mh-folder.c62
4 files changed, 100 insertions, 71 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 31321e9bab..f1d9e274a2 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,15 @@
+2001-05-25 Jeffrey Stedfast <fejj@ximian.com>
+
+ * providers/local/camel-maildir-folder.c (maildir_append_message):
+ remove the summary info so we are not out-of-sync with the maildir
+ folder.
+
+ * providers/local/camel-mh-folder.c (mh_append_message): remove
+ the summary info so we are not out-of-sync with the mh folder.
+
+ * providers/local/camel-mbox-folder.c (mbox_append_message):
+ remove the summary info so we are not out-of-sync with the mbox.
+
2001-05-24 Jeffrey Stedfast <fejj@ximian.com>
* camel-smime-context.c (camel_smime_context_new): Oops, I spelled
diff --git a/camel/providers/local/camel-maildir-folder.c b/camel/providers/local/camel-maildir-folder.c
index 198e4ebc00..a60b315e0e 100644
--- a/camel/providers/local/camel-maildir-folder.c
+++ b/camel/providers/local/camel-maildir-folder.c
@@ -121,64 +121,68 @@ static CamelLocalSummary *maildir_create_summary(const char *path, const char *f
return (CamelLocalSummary *)camel_maildir_summary_new(path, folder, index);
}
-static void maildir_append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, CamelException * ex)
+static void
+maildir_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, CamelException *ex)
{
CamelMaildirFolder *maildir_folder = (CamelMaildirFolder *)folder;
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
CamelStream *output_stream;
CamelMessageInfo *mi;
CamelMaildirMessageInfo *mdi;
- char *name, *dest;
-
+ char *name, *dest = NULL;
+
d(printf("Appending message\n"));
/* add it to the summary/assign the uid, etc */
mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, ex);
- if (camel_exception_is_set(ex)) {
+ if (camel_exception_is_set (ex))
return;
- }
-
+
mdi = (CamelMaildirMessageInfo *)mi;
d(printf("Appending message: uid is %s filename is %s\n", camel_message_info_uid(mi), mdi->filename));
/* write it out to tmp, use the uid we got from the summary */
- name = g_strdup_printf("%s/tmp/%s", lf->folder_path, camel_message_info_uid(mi));
- output_stream = camel_stream_fs_new_with_name(name, O_WRONLY|O_CREAT, 0600);
- if (output_stream == NULL) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot append message to maildir folder: %s: %s"), name, g_strerror(errno));
- g_free(name);
- return;
- }
-
- if (camel_data_wrapper_write_to_stream((CamelDataWrapper *)message, output_stream) == -1
- || camel_stream_close(output_stream) == -1) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot append message to maildir folder: %s: %s"), name, g_strerror(errno));
- camel_object_unref((CamelObject *)output_stream);
- unlink(name);
- g_free(name);
- return;
- }
-
+ name = g_strdup_printf ("%s/tmp/%s", lf->folder_path, camel_message_info_uid(mi));
+ output_stream = camel_stream_fs_new_with_name (name, O_WRONLY|O_CREAT, 0600);
+ if (output_stream == NULL)
+ goto fail_write;
+
+ if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *)message, output_stream) == -1
+ || camel_stream_close (output_stream) == -1)
+ goto fail_write;
+
/* now move from tmp to cur (bypass new, does it matter?) */
- dest = g_strdup_printf("%s/cur/%s", lf->folder_path, camel_maildir_info_filename(mdi));
- if (rename(name, dest) == 1) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot append message to maildir folder: %s: %s"), name, g_strerror(errno));
- camel_object_unref((CamelObject *)output_stream);
- unlink(name);
- g_free(name);
- g_free(dest);
- return;
+ dest = g_strdup_printf("%s/cur/%s", lf->folder_path, camel_maildir_info_filename (mdi));
+ if (rename (name, dest) == 1)
+ goto fail_write;
+
+ g_free (dest);
+ g_free (name);
+
+ camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed",
+ ((CamelLocalFolder *)maildir_folder)->changes);
+ camel_folder_change_info_clear (((CamelLocalFolder *)maildir_folder)->changes);
+
+ return;
+
+ fail_write:
+
+ /* remove the summary info so we are not out-of-sync with the mh folder */
+ camel_folder_summary_remove_uid (CAMEL_FOLDER_SUMMARY (folder->summary),
+ camel_message_info_uid (mi));
+
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Cannot append message to maildir folder: %s: %s"),
+ name, g_strerror (errno));
+
+ if (output_stream) {
+ camel_object_unref (CAMEL_OBJECT (output_stream));
+ unlink (name);
}
-
- g_free(dest);
- g_free(name);
-
- camel_object_trigger_event((CamelObject *)folder, "folder_changed", ((CamelLocalFolder *)maildir_folder)->changes);
- camel_folder_change_info_clear(((CamelLocalFolder *)maildir_folder)->changes);
+
+ g_free (name);
+ g_free (dest);
}
static CamelMimeMessage *maildir_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex)
diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c
index 9db90fb40c..5d0d816d27 100644
--- a/camel/providers/local/camel-mbox-folder.c
+++ b/camel/providers/local/camel-mbox-folder.c
@@ -255,8 +255,9 @@ mbox_append_message(CamelFolder *folder, CamelMimeMessage * message, const Camel
return;
fail_write:
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot append message to mbox file: %s: %s"), lf->folder_path, strerror(errno));
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Cannot append message to mbox file: %s: %s"),
+ lf->folder_path, g_strerror (errno));
if (filter_stream)
camel_object_unref(CAMEL_OBJECT(filter_stream));
@@ -271,18 +272,20 @@ fail_write:
/* reset the file to original size */
fd = open(lf->folder_path, O_WRONLY, 0600);
-
if (fd != -1) {
ftruncate(fd, mbs->folder_size);
close(fd);
}
-
+
+ /* remove the summary info so we are not out-of-sync with the mbox */
+ camel_folder_summary_remove_uid (CAMEL_FOLDER_SUMMARY (mbs), camel_message_info_uid (mi));
+
/* and tell the summary its uptodate */
if (stat(lf->folder_path, &st) == 0) {
mbs->folder_size = st.st_size;
((CamelFolderSummary *)mbs)->time = st.st_mtime;
}
-
+
fail:
/* make sure we unlock the folder - before we start triggering events into appland */
camel_local_folder_unlock(lf);
diff --git a/camel/providers/local/camel-mh-folder.c b/camel/providers/local/camel-mh-folder.c
index cdf636b533..88ef69c2b5 100644
--- a/camel/providers/local/camel-mh-folder.c
+++ b/camel/providers/local/camel-mh-folder.c
@@ -121,7 +121,8 @@ static CamelLocalSummary *mh_create_summary(const char *path, const char *folder
return (CamelLocalSummary *)camel_mh_summary_new(path, folder, index);
}
-static void mh_append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, CamelException * ex)
+static void
+mh_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, CamelException *ex)
{
CamelMhFolder *mh_folder = (CamelMhFolder *)folder;
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
@@ -135,39 +136,48 @@ static void mh_append_message(CamelFolder * folder, CamelMimeMessage * message,
/* add it to the summary/assign the uid, etc */
mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, ex);
- if (camel_exception_is_set(ex)) {
+ if (camel_exception_is_set (ex))
return;
- }
-
+
d(printf("Appending message: uid is %s\n", camel_message_info_uid(mi)));
-
+
/* write it out, use the uid we got from the summary */
name = g_strdup_printf("%s/%s", lf->folder_path, camel_message_info_uid(mi));
output_stream = camel_stream_fs_new_with_name(name, O_WRONLY|O_CREAT, 0600);
- if (output_stream == NULL) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot append message to mh folder: %s: %s"), name, g_strerror(errno));
- g_free(name);
- return;
- }
-
- if (camel_data_wrapper_write_to_stream((CamelDataWrapper *)message, output_stream) == -1
- || camel_stream_close(output_stream) == -1) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot append message to mh folder: %s: %s"), name, g_strerror(errno));
- camel_object_unref((CamelObject *)output_stream);
- unlink(name);
- g_free(name);
- return;
- }
-
+ if (output_stream == NULL)
+ goto fail_write;
+
+ if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *)message, output_stream) == -1
+ || camel_stream_close (output_stream) == -1)
+ goto fail_write;
+
/* close this? */
- camel_object_unref((CamelObject *)output_stream);
+ camel_object_unref (CAMEL_OBJECT (output_stream));
g_free(name);
-
- camel_object_trigger_event((CamelObject *)folder, "folder_changed", ((CamelLocalFolder *)mh_folder)->changes);
- camel_folder_change_info_clear(((CamelLocalFolder *)mh_folder)->changes);
+
+ camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed",
+ ((CamelLocalFolder *)mh_folder)->changes);
+ camel_folder_change_info_clear (((CamelLocalFolder *)mh_folder)->changes);
+
+ return;
+
+ fail_write:
+
+ /* remove the summary info so we are not out-of-sync with the mh folder */
+ camel_folder_summary_remove_uid (CAMEL_FOLDER_SUMMARY (folder->summary),
+ camel_message_info_uid (mi));
+
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Cannot append message to mh folder: %s: %s"),
+ name, g_strerror (errno));
+
+ if (output_stream) {
+ camel_object_unref (CAMEL_OBJECT (output_stream));
+ unlink (name);
+ }
+
+ g_free (name);
}
static CamelMimeMessage *mh_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex)