aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2004-01-21 03:48:03 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2004-01-21 03:48:03 +0800
commit19b195d9e8daa7a9ea36abb8388ffdb6eb578829 (patch)
treec7c97937a3bd632c64ca441315f7d2975ba7700c
parent254104e3129ae52a820860bdd0e4bdc76e69511c (diff)
downloadgsoc2013-evolution-19b195d9e8daa7a9ea36abb8388ffdb6eb578829.tar
gsoc2013-evolution-19b195d9e8daa7a9ea36abb8388ffdb6eb578829.tar.gz
gsoc2013-evolution-19b195d9e8daa7a9ea36abb8388ffdb6eb578829.tar.bz2
gsoc2013-evolution-19b195d9e8daa7a9ea36abb8388ffdb6eb578829.tar.lz
gsoc2013-evolution-19b195d9e8daa7a9ea36abb8388ffdb6eb578829.tar.xz
gsoc2013-evolution-19b195d9e8daa7a9ea36abb8388ffdb6eb578829.tar.zst
gsoc2013-evolution-19b195d9e8daa7a9ea36abb8388ffdb6eb578829.zip
New function to migrate the imap cache. (em_migrate_1_4): Migrate the IMAP
2004-01-20 Jeffrey Stedfast <fejj@ximian.com> * em-migrate.c (em_migrate_imap_caches_1_4): New function to migrate the imap cache. (em_migrate_1_4): Migrate the IMAP cache. Fixes bug #52985. svn path=/trunk/; revision=24330
-rw-r--r--mail/ChangeLog4
-rw-r--r--mail/em-migrate.c81
2 files changed, 82 insertions, 3 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 5b349892f2..cfe04b165a 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,9 @@
2004-01-20 Jeffrey Stedfast <fejj@ximian.com>
+ * em-migrate.c (em_migrate_imap_caches_1_4): New function to
+ migrate the imap cache.
+ (em_migrate_1_4): Migrate the IMAP cache. Fixes bug #52985.
+
* mail-session.c (request_password): Changed the logic of the
visibility of the passwd text so that we hid ethe passwd if the
flags have the SECRET bit set.
diff --git a/mail/em-migrate.c b/mail/em-migrate.c
index 533228d2e3..91758ee4ae 100644
--- a/mail/em-migrate.c
+++ b/mail/em-migrate.c
@@ -1255,7 +1255,7 @@ cp (const char *src, const char *dest, gboolean show_progress)
if ((fd[0] = open (src, O_RDONLY)) == -1)
return -1;
- if ((fd[1] = open (dest, O_WRONLY | O_CREAT | O_TRUNC, 0666)) == -1) {
+ if ((fd[1] = open (dest, O_WRONLY | O_CREAT | O_TRUNC, st.st_mode & 0666)) == -1) {
errnosav = errno;
close (fd[0]);
errno = errnosav;
@@ -1306,6 +1306,56 @@ cp (const char *src, const char *dest, gboolean show_progress)
return -1;
}
+static int
+cp_r (const char *src, const char *dest)
+{
+ GString *srcpath, *destpath;
+ struct dirent *dent;
+ size_t slen, dlen;
+ struct stat st;
+ DIR *dir;
+
+ if (camel_mkdir (dest, st.st_mode & 0777) == -1)
+ return -1;
+
+ if (!(dir = opendir (src)))
+ return -1;
+
+ srcpath = g_string_new (src);
+ g_string_append_c (srcpath, '/');
+ slen = srcpath->len;
+
+ destpath = g_string_new (dest);
+ g_string_append_c (destpath, '/');
+ dlen = destpath->len;
+
+ while ((dent = readdir (dir))) {
+ if (!strcmp (dent->d_name, ".") || !strcmp (dent->d_name, ".."))
+ continue;
+
+ g_string_truncate (srcpath, slen);
+ g_string_truncate (destpath, dlen);
+
+ g_string_append (srcpath, dent->d_name);
+ g_string_append (destpath, dent->d_name);
+
+ if (stat (srcpath->str, &st) == -1)
+ continue;
+
+ if (S_ISDIR (st.st_mode))
+ cp_r (srcpath->str, destpath->str);
+ else
+ cp (srcpath->str, destpath->str, FALSE);
+ }
+
+ closedir (dir);
+
+ g_string_free (destpath, TRUE);
+ g_string_free (srcfpath, TRUE);
+
+ return 0;
+}
+
static GString *
mbox_build_filename (const char *toplevel_dir, const char *full_name)
{
@@ -1675,7 +1725,7 @@ em_upgrade_xml_1_4 (xmlDocPtr doc)
}
static int
-em_upgrade_pop_uid_caches_1_4 (const char *evolution_dir, CamelException *ex)
+em_migrate_pop_uid_caches_1_4 (const char *evolution_dir, CamelException *ex)
{
GString *oldpath, *newpath;
struct dirent *dent;
@@ -1751,6 +1801,28 @@ em_upgrade_pop_uid_caches_1_4 (const char *evolution_dir, CamelException *ex)
return 0;
}
+static int
+em_migrate_imap_caches_1_4 (const char *evolution_dir, CamelException *ex)
+{
+ char *src, *dest;
+ struct stat st;
+
+ src = g_build_filename (g_get_home_dir (), "evolution", "mail", "imap", NULL);
+ if (stat (src, &st) == -1 || !S_ISDIR (st.st_mode)) {
+ g_free (src);
+ return 0;
+ }
+
+ dest = g_build_filename (evolution_dir, "imap", NULL);
+
+ /* we don't care if this fails, it's only a cache... */
+ cp_r (src, dest);
+
+ g_free (dest);
+ g_free (src);
+
+ return 0;
+}
static int
em_migrate_1_4 (const char *evolution_dir, xmlDocPtr filters, xmlDocPtr vfolders, CamelException *ex)
@@ -1807,7 +1879,10 @@ em_migrate_1_4 (const char *evolution_dir, xmlDocPtr filters, xmlDocPtr vfolders
if (em_upgrade_xml_1_4 (vfolders) == -1)
return -1;
- if (em_upgrade_pop_uid_caches_1_4 (evolution_dir, ex) == -1)
+ if (em_migrate_pop_uid_caches_1_4 (evolution_dir, ex) == -1)
+ return -1;
+
+ if (em_migrate_imap_caches_1_4 (evolution_dir, ex) == -1)
return -1;
return 0;