aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--camel/ChangeLog25
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c15
-rw-r--r--camel/providers/mbox/camel-mbox-parser.c31
-rw-r--r--camel/providers/mbox/camel-mbox-summary.c75
4 files changed, 96 insertions, 50 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 7ff2cf9557..155bc3fb0f 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,28 @@
+2000-04-01 Dan Winship <danw@helixcode.com>
+
+ * 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. :-)
+
2000-03-31 Dan Winship <danw@helixcode.com>
* camel-stream-mem.c: implement unimplemented methods
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);
}
diff --git a/camel/providers/mbox/camel-mbox-parser.c b/camel/providers/mbox/camel-mbox-parser.c
index 7c0eec5379..c03639133f 100644
--- a/camel/providers/mbox/camel-mbox-parser.c
+++ b/camel/providers/mbox/camel-mbox-parser.c
@@ -584,20 +584,29 @@ read_message_begining (CamelMboxPreParser *parser, gchar **message_summary)
/**
* camel_mbox_parse_file: read an mbox file and parse it.
* @fd: file descriptor opened on the mbox file.
- * @message_delimiter: character string delimiting the beginig of a new message
- * @start_position: poition in the file where to start the parsing.
- * @get_message_summary: should the parser retrieve the begining of the messages
- * @status_callback: function to call peridically to indicate the progress of the parser
- * @status_interval: floating value between 0 and 1 indicate how often to call @status_callback.
+ * @message_delimiter: character string delimiting the beginig of a
+ * new message
+ * @start_position: position in the file where to start the parsing.
+ * @file_size: on output, the size in bytes of the file
+ * @next_uid: on output, the next uid available for use
+ * @get_message_summary: should the parser retrieve the begining of
+ * the messages
+ * @status_callback: function to call peridically to indicate the
+ * progress of the parser
+ * @status_interval: floating value between 0 and 1 indicate how often
+ * to call @status_callback.
* @user_data: user data that will be passed to the callback function
*
- * This routine parses an mbox file and retreives both the message starting positions and
- * some of the informations contained in the message. Those informations are mainly
- * some RFC822 headers values but also (optionally) the first characters of the mail
- * body. The @get_message_summary parameter allows to enable or disable this option.
+ * This routine parses an mbox file and retreives both the message
+ * starting positions and some of the informations contained in the
+ * message. Those informations are mainly some RFC822 headers values
+ * but also (optionally) the first characters of the mail body. The
+ * @get_message_summary parameter allows to enable or disable this
+ * option.
*
*
- * Return value: An array of CamelMboxParserMessageInfo containing the informations on each message parsed in the file
+ * Return value: An array of CamelMboxParserMessageInfo containing the
+ * informations on each message parsed in the file
**/
GArray *
camel_mbox_parse_file (int fd,
@@ -766,7 +775,7 @@ camel_mbox_parse_file (int fd,
G_STRUCT_OFFSET (CamelMboxPreParser, current_message_info) +
G_STRUCT_OFFSET (CamelMboxParserMessageInfo, status)));
g_free (x_ev_header_content);
- next_available_uid = MAX (next_available_uid, parser->current_message_info.uid);
+ next_available_uid = MAX (next_available_uid, parser->current_message_info.uid + 1);
newline = TRUE;
continue;
diff --git a/camel/providers/mbox/camel-mbox-summary.c b/camel/providers/mbox/camel-mbox-summary.c
index a6561d60f0..69c720b091 100644
--- a/camel/providers/mbox/camel-mbox-summary.c
+++ b/camel/providers/mbox/camel-mbox-summary.c
@@ -174,6 +174,7 @@ camel_mbox_summary_save (CamelMboxSummary *summary, const gchar *filename,
gint fd;
gint write_result; /* XXX use this */
guint32 data;
+ struct stat st;
CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::save_summary entering \n");
@@ -192,16 +193,16 @@ camel_mbox_summary_save (CamelMboxSummary *summary, const gchar *filename,
* that makes sense, but because it's easy.
*/
- data = htons (CAMEL_MBOX_SUMMARY_VERSION);
+ data = htonl (CAMEL_MBOX_SUMMARY_VERSION);
write (fd, &data, sizeof (data));
- data = htons (summary->nb_message);
+ data = htonl (summary->nb_message);
write (fd, &data, sizeof (data));
- data = htons (summary->next_uid);
+ data = htonl (summary->next_uid);
write (fd, &data, sizeof (data));
- data = htons (summary->mbox_file_size);
+ data = htonl (summary->mbox_file_size);
write (fd, &data, sizeof (data));
- data = htons (summary->mbox_modtime);
+ data = htonl (summary->mbox_modtime);
write (fd, &data, sizeof (data));
for (cur_msg = 0; cur_msg < summary->nb_message; cur_msg++) {
@@ -209,62 +210,67 @@ camel_mbox_summary_save (CamelMboxSummary *summary, const gchar *filename,
(summary->message_info->data) + cur_msg;
/* Write meta-info. */
- data = htons (msg_info->position);
+ data = htonl (msg_info->position);
write (fd, &data, sizeof (data));
- data = htons (msg_info->size);
+ data = htonl (msg_info->size);
write (fd, &data, sizeof (data));
- data = htons (msg_info->x_evolution_offset);
+ data = htonl (msg_info->x_evolution_offset);
write (fd, &data, sizeof (data));
- data = htons (msg_info->uid);
+ data = htonl (msg_info->uid);
write (fd, &data, sizeof (data));
write (fd, &msg_info->status, 1);
/* Write subject. */
if (msg_info->headers.subject)
- field_length = htons (strlen (msg_info->headers.subject));
+ field_length = strlen (msg_info->headers.subject);
else
field_length = 0;
- write (fd, &field_length, sizeof (field_length));
+ data = htonl (field_length);
+ write (fd, &data, sizeof (data));
if (msg_info->headers.subject)
write (fd, msg_info->headers.subject, field_length);
/* Write sender. */
if (msg_info->headers.sender)
- field_length = htons (strlen (msg_info->headers.sender));
+ field_length = strlen (msg_info->headers.sender);
else
field_length = 0;
- write (fd, &field_length, sizeof (field_length));
+ data = htonl (field_length);
+ write (fd, &data, sizeof (data));
if (msg_info->headers.sender)
write (fd, msg_info->headers.sender, field_length);
/* Write to. */
if (msg_info->headers.to)
- field_length = htons (strlen (msg_info->headers.to));
+ field_length = strlen (msg_info->headers.to);
else
field_length = 0;
- write (fd, &field_length, sizeof (field_length));
+ data = htonl (field_length);
+ write (fd, &data, sizeof (data));
if (msg_info->headers.to)
write (fd, msg_info->headers.to, field_length);
/* Write sent date. */
if (msg_info->headers.sent_date)
- field_length = htons (strlen (msg_info->headers.sent_date));
+ field_length = strlen (msg_info->headers.sent_date);
else
field_length = 0;
- write (fd, &field_length, sizeof (field_length));
+ data = htonl (field_length);
+ write (fd, &data, sizeof (data));
if (msg_info->headers.sent_date)
write (fd, msg_info->headers.sent_date, field_length);
/* Write received date. */
if (msg_info->headers.received_date)
- field_length = htons (strlen (msg_info->headers.received_date));
+ field_length = strlen (msg_info->headers.received_date);
else
field_length = 0;
- write (fd, &field_length, sizeof (field_length));
+ data = htonl (field_length);
+ write (fd, &data, sizeof (data));
if (msg_info->headers.received_date)
write (fd, msg_info->headers.received_date, field_length);
}
-
+
close (fd);
CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::save_summary leaving \n");
@@ -305,7 +311,7 @@ camel_mbox_summary_load (const gchar *filename, CamelException *ex)
/* Verify version number. */
read (fd, &data, sizeof(data));
- data = ntohs (data);
+ data = ntohl (data);
if (data != CAMEL_MBOX_SUMMARY_VERSION) {
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_SUMMARY_INVALID,
@@ -319,13 +325,13 @@ camel_mbox_summary_load (const gchar *filename, CamelException *ex)
summary = CAMEL_MBOX_SUMMARY (gtk_object_new (camel_mbox_summary_get_type (), NULL));
read (fd, &data, sizeof(data));
- summary->nb_message = ntohs (data);
+ summary->nb_message = ntohl (data);
read (fd, &data, sizeof(data));
- summary->next_uid = ntohs (data);
+ summary->next_uid = ntohl (data);
read (fd, &data, sizeof(data));
- summary->mbox_file_size = ntohs (data);
+ summary->mbox_file_size = ntohl (data);
read (fd, &data, sizeof(data));
- summary->mbox_modtime = ntohs (data);
+ summary->mbox_modtime = ntohl (data);
summary->message_info =
g_array_new (FALSE, FALSE,
@@ -338,20 +344,19 @@ camel_mbox_summary_load (const gchar *filename, CamelException *ex)
/* Read the meta-info. */
read (fd, &data, sizeof(data));
- msg_info->position = ntohs (data);
+ msg_info->position = ntohl (data);
read (fd, &data, sizeof(data));
- msg_info->size = ntohs (data);
+ msg_info->size = ntohl (data);
read (fd, &data, sizeof(data));
- msg_info->x_evolution_offset = ntohs (data);
- read (fd, &(msg_info->status), 1);
+ msg_info->x_evolution_offset = ntohl (data);
read (fd, &data, sizeof(data));
- msg_info->uid = ntohs (data);
+ msg_info->uid = ntohl (data);
msg_info->headers.uid = g_strdup_printf ("%d", msg_info->uid);
read (fd, &msg_info->status, 1);
/* Read the subject. */
read (fd, &field_length, sizeof (field_length));
- field_length = ntohs (field_length);
+ field_length = ntohl (field_length);
if (field_length > 0) {
msg_info->headers.subject =
g_new0 (gchar, field_length + 1);
@@ -361,7 +366,7 @@ camel_mbox_summary_load (const gchar *filename, CamelException *ex)
/* Read the sender. */
read (fd, &field_length, sizeof (field_length));
- field_length = ntohs (field_length);
+ field_length = ntohl (field_length);
if (field_length > 0) {
msg_info->headers.sender =
g_new0 (gchar, field_length + 1);
@@ -371,7 +376,7 @@ camel_mbox_summary_load (const gchar *filename, CamelException *ex)
/* Read the "to" field. */
read (fd, &field_length, sizeof (field_length));
- field_length = ntohs (field_length);
+ field_length = ntohl (field_length);
if (field_length > 0) {
msg_info->headers.to =
g_new0 (gchar, field_length + 1);
@@ -381,7 +386,7 @@ camel_mbox_summary_load (const gchar *filename, CamelException *ex)
/* Read the sent date field. */
read (fd, &field_length, sizeof (field_length));
- field_length = ntohs (field_length);
+ field_length = ntohl (field_length);
if (field_length > 0) {
msg_info->headers.sent_date =
g_new0 (gchar, field_length + 1);
@@ -391,7 +396,7 @@ camel_mbox_summary_load (const gchar *filename, CamelException *ex)
/* Read the received date field. */
read (fd, &field_length, sizeof (field_length));
- field_length = ntohs (field_length);
+ field_length = ntohl (field_length);
if (field_length > 0) {
msg_info->headers.received_date =
g_new0 (gchar, field_length + 1);
3 01:11:40 +0800'>2015-12-234-0/+40 * archivers/peazip: Make less broken, then mark BROKENmarino2015-12-221-1/+3 * - Strip shared librarysunpoet2015-12-221-1/+4 * - Strip shared librarysunpoet2015-12-221-1/+4 * - Convert rpm2cpio to shell script around bsdtarak2015-12-183-115/+19 * Fix build and remove an unused REINPLACE_ARGS variable.jkim2015-12-181-3/+2 * Fix usage of ${PERL5}.mat2015-12-181-2/+3 * - Minor fixesak2015-12-172-6/+6 * Fix `make fetch'rakuco2015-12-151-2/+1 * Reset maintainereadler2015-12-141-1/+1 * Mark as broken: unfetchablebapt2015-12-131-0/+2 * mirrorservice.org no longer mirrors this ftpbapt2015-12-131-2/+1 * - Switch to options helpersamdmi32015-12-121-3/+4 * - Switch to options helpersamdmi32015-12-081-0/+2 * - Update to 1.55sunpoet2015-12-072-3/+5 * FPC ecosystem: Upgrade version 2.6.4 => 3.0.0marino2015-12-067-88/+7 * - Update to 15.09sunpoet2015-12-047-98/+43 * Inno Setup is a tool to create installers for Microsoft Windows applications.amdmi32015-12-024-0/+34 * Finish pyliblzma rename (and unbreak dependent ports)antoine2015-11-301-3/+2 * archivers/py-liblzma: Rename to pylibzma, Modernizekoobs2015-11-307-34/+59 * Remove expired ports:rene2015-11-294-39/+0 * - Take Maintainershipmiwi2015-11-263-3/+3 * - Take Maintainershipmiwi2015-11-262-2/+2 * - Add LICENSEsunpoet2015-11-201-7/+12 * archivers/upx: Expand patch to support malloc.h-less DFmarino2015-11-131-3/+12 * archivers/py-liblzma: Fix horrible malloc.h handlingmarino2015-11-131-0/+16 * - Clarify LICENSEamdmi32015-11-121-1/+4 * - Switch to options helpersamdmi32015-11-111-0/+4 * - Add LICENSEamdmi32015-11-101-4/+9 * Mark a few ports BROKEN: unfetchableantoine2015-11-091-0/+2 * Fix ports that confused the meaning of WRKDIR and WRKSRC.mat2015-11-053-5/+5 * - Add LICENSE_FILEsunpoet2015-11-051-1/+2 * - Add LICENSE_FILEsunpoet2015-11-051-0/+1 * - Remove BROKEN from archivers/hlextractdanilo2015-10-301-5/+1 * Fix path.demon2015-10-271-1/+1 * Update to version 2.22.demon2015-10-272-4/+6 * Deprecate ports broken for more than 6 monthsantoine2015-10-262-0/+4 * archivers/zopfli: update to 1.0.1jbeich2015-10-242-4/+4 * Mark as broken: does not fetchbapt2015-10-241-0/+1 * - Add LICENSE_FILEamdmi32015-10-151-0/+1 * Use the new test framework in my ports, if applicable.naddy2015-10-142-9/+5 * - Reset MAINTAINER due to fatal bouncezi2015-10-111-1/+1 * Remove trailing whitespace from Makefiles, A-L.olgeni2015-10-081-1/+1 * - cleanupdinoex2015-10-081-2/+1 * - Silence patchingamdmi32015-10-072-4/+4 * Reassign some of my ports to the Collective.adamw2015-10-061-1/+1 * Add USES=alias to 4 ports (Aids DragonFly support)marino2015-10-051-0/+1 * Update PHP ports to versions 5.5.30 and 5.6.14.ale2015-10-051-1/+0 * - Fix build on 9.xsunpoet2015-10-052-1/+880 * - Add brotli 0.2.0sunpoet2015-10-014-0/+41 * 1: Upgrade to 1.05.vanilla2015-10-013-8/+11 * archivers/snappy: fix buildswills2015-09-301-1/+1 * Change WWW to current site.vanilla2015-09-301-1/+1 * 1: Upgrade to 1.1.3.vanilla2015-09-303-7/+10 * - Update to 2.069sunpoet2015-09-282-4/+4 * - Update to 2.069sunpoet2015-09-282-5/+5 * - Update to 2.069sunpoet2015-09-282-4/+4 * - Update to 2.069sunpoet2015-09-282-5/+5 * - Update to 2.069sunpoet2015-09-282-4/+3 * - Update to 2.069sunpoet2015-09-282-4/+3 * - Update to 2.069sunpoet2015-09-282-4/+3 * - Switch to options helpersamdmi32015-09-251-7/+2 * - Update to 1.53sunpoet2015-09-252-3/+3 * - Update to 1.51sunpoet2015-09-232-3/+3 * Update to version 1.18.3pawel2015-09-232-3/+3 * - Update to 5.30 Beta 4 (5.3.4)sunpoet2015-09-215-11/+10 * Typos, whitespace and capitalization fixes (A-F).olgeni2015-09-211-1/+1 * Build fix for FreeBSD 9. Define variable, since the old make throwsnaddy2015-09-201-0/+10 * Make all GNUstep ports install into the System domain so that the Local domai...theraven2015-09-194-36/+36 * Update to 2.12, but retain local fix for CVE-2015-1197.naddy2015-09-1813-188/+73 * - Replace '--touch' option with '-m'danilo2015-09-174-2/+167 * Apply patch to fix directory traversal vulnerabilityfeld2015-09-172-1/+284 * archivers/zopfli is not jobs safemarino2015-09-101-0/+2 * It turned out -fPIC is required on sparc64 as well: it dumps core withoutdanfe2015-09-091-0/+1 * Compile with -fPIC on PowerPC, otherwise resulting binaries are broken:danfe2015-09-091-1/+2 * - Add an upstream patch for archivers/py-lz4 to export its version number.jkim2015-09-053-1/+32 * Update file-roller to 3.16.4.kwm2015-09-043-18/+3 * - Add LICENSEsunpoet2015-09-042-28/+26 * - Update to 1.1.12farrokhi2015-09-032-6/+5 * Update devel/tbb to 4.4.0 and bump dependent ports' revisionsmartymac2015-09-03