aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/mbox/camel-mbox-folder.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-04-02 05:58:27 +0800
committerDan Winship <danw@src.gnome.org>2000-04-02 05:58:27 +0800
commit9e7dabfa8274777916da364b50284cfa51ac9a6f (patch)
tree579b255f6178357a1c2d9e697a423636fb65d619 /camel/providers/mbox/camel-mbox-folder.c
parent98690e9f75e909483f857f23bae0f903ee1ed84a (diff)
downloadgsoc2013-evolution-9e7dabfa8274777916da364b50284cfa51ac9a6f.tar.gz
gsoc2013-evolution-9e7dabfa8274777916da364b50284cfa51ac9a6f.tar.zst
gsoc2013-evolution-9e7dabfa8274777916da364b50284cfa51ac9a6f.zip
Compare mbox_file_size and mbox_modtime to the results of stat()ing the
* providers/mbox/camel-mbox-folder.c (_check_get_or_maybe_generate_summary_file): Compare mbox_file_size and mbox_modtime to the results of stat()ing the mbox file, not the summary file. Duh. (_close): Update the summary's mbox_file_size and mbox_modtime before writing it to disk. * providers/mbox/camel-mbox-summary.c (camel_mbox_summary_save, camel_mbox_summary_load): Wow. I must have been tired when I wrote this code. First, the comparison bug above. Second, it was using ntohs and htons instead of ntohl and htonl. Third, I was reading the status flag byte in two different places and thus getting out of sync. Fourth, it was writing out field_length bytes of each header field after having converted field_length to network byte order, resulting in lots of random crap being appended, and the summary files being huge. (Fortunately, since the size/modtime comparison was biffed, the garbage summary read from disk was always immediately discarded.) * providers/mbox/camel-mbox-parser.c (camel_mbox_parse_file): fix an off-by-one error that caused the last-used UID to be reused if the summary file was regenerated. (That one wasn't my fault. :-) svn path=/trunk/; revision=2279
Diffstat (limited to 'camel/providers/mbox/camel-mbox-folder.c')
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index b376f67fbd..8e1fe00402 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -221,11 +221,12 @@ _check_get_or_maybe_generate_summary_file (CamelMboxFolder *mbox_folder,
folder->summary = NULL;
/* Test for the existence and up-to-dateness of the summary file. */
- if (stat (mbox_folder->summary_file_path, &st) == 0) {
+ if (access (mbox_folder->summary_file_path, F_OK) == 0) {
summ = camel_mbox_summary_load (mbox_folder->summary_file_path,
ex);
if (summ) {
- if (summ->mbox_file_size == st.st_size &&
+ if (stat (mbox_folder->folder_file_path, &st) == 0 &&
+ summ->mbox_file_size == st.st_size &&
summ->mbox_modtime == st.st_mtime)
folder->summary = CAMEL_FOLDER_SUMMARY (summ);
else
@@ -318,6 +319,8 @@ static void
_close (CamelFolder *folder, gboolean expunge, CamelException *ex)
{
CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
+ CamelMboxSummary *mbox_summary = CAMEL_MBOX_SUMMARY (folder->summary);
+ struct stat st;
/* call parent implementation */
parent_class->close (folder, expunge, ex);
@@ -327,8 +330,12 @@ _close (CamelFolder *folder, gboolean expunge, CamelException *ex)
ibex_close(mbox_folder->index);
}
- /* save the folder summary on disk */
- camel_mbox_summary_save (CAMEL_MBOX_SUMMARY (folder->summary),
+ /* Update the summary and save it to disk */
+ if (stat (mbox_folder->folder_file_path, &st) == 0) {
+ mbox_summary->mbox_file_size = st.st_size;
+ mbox_summary->mbox_modtime = st.st_mtime;
+ }
+ camel_mbox_summary_save (mbox_summary,
mbox_folder->summary_file_path, ex);
}