From 5df4d0a321a1890780f43c715681176c64f01594 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 2 Jan 2002 18:04:46 +0000 Subject: The idea here is that if we consistantly name the movemail file between 2001-12-21 Jeffrey Stedfast The idea here is that if we consistantly name the movemail file between Send&Receive sessions that if the user cancells the "download" of a mbox spool that the next Send&Receive will not "lose" mail that didn't finish the previous session. Fixes bug #17759. Well, mostly. If you have 200 messages and cancel after the first 100, say, then the next time you hit Send&Receive, it will start over from 1 so you'll end up duplicating the first 100 messages, but at least you won't "lose" mail. * mail-tools.c (mail_tool_get_local_movemail_path): Now a static internal function, takes a char *uri argument and no longer generates movemail.%d filenames... they are now based on the uri provided. (mail_tool_do_movemail): Pass along the source_uri. svn path=/trunk/; revision=15224 --- mail/mail-tools.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'mail/mail-tools.c') diff --git a/mail/mail-tools.c b/mail/mail-tools.c index 9d94fb1e78..d80b3c04fa 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -47,22 +47,6 @@ /* **************************************** */ -gchar * -mail_tool_get_local_movemail_path (void) -{ - static gint count = 0; - static pthread_mutex_t movemail_path_lock = PTHREAD_MUTEX_INITIALIZER; - gint my_count; - - /* Ah, the joys of being multi-threaded... */ - pthread_mutex_lock (&movemail_path_lock); - my_count = count; - ++count; - pthread_mutex_unlock (&movemail_path_lock); - - return g_strdup_printf ("%s/local/Inbox/movemail.%d", evolution_dir, my_count); -} - CamelFolder * mail_tool_get_local_inbox (CamelException *ex) { @@ -115,18 +99,35 @@ mail_tool_get_trash (const gchar *url, int connect, CamelException *ex) return trash; } +static char * +mail_tool_get_local_movemail_path (const unsigned char *uri) +{ + unsigned char *safe_uri, *c; + char *path; + + safe_uri = g_strdup (uri); + for (c = safe_uri; *c; c++) + if (strchr ("/:;=|%&#!*^()\\, ", *c) || !isprint ((int) *c)) + *c = '_'; + + path = g_strdup_printf ("%s/local/Inbox/movemail.%s", evolution_dir, safe_uri); + g_free (safe_uri); + + return path; +} + /* why is this function so stupidly complex when allthe work is done elsehwere? */ char * -mail_tool_do_movemail (const gchar *source_url, CamelException *ex) +mail_tool_do_movemail (const char *source_url, CamelException *ex) { - gchar *dest_path; - const gchar *source; + char *dest_path; + const char *source; struct stat sb; - + g_return_val_if_fail (strncmp (source_url, "mbox:", 5) == 0, NULL); /* Set up our destination. */ - dest_path = mail_tool_get_local_movemail_path(); + dest_path = mail_tool_get_local_movemail_path (source_url); /* Skip over "mbox:" plus host part (if any) of url. */ source = source_url + 5; -- cgit