diff options
| author | Not Zed <NotZed@Ximian.com> | 2005-08-09 04:01:43 +0000 |
|---|---|---|
| committer | Michael Zucci <zucchi@src.gnome.org> | 2005-08-09 04:01:43 +0000 |
| commit | 7b8d1e5139a33303f14c708427cc6f6b2ea8fc8f (patch) | |
| tree | 5ceb071aac552b4d0b94078db5f52687c1d98d20 | |
| parent | d322949b9fa89c791d5d6bfe9b452a6521868790 (diff) | |
| download | evolution-data-server-7b8d1e5139a33303f14c708427cc6f6b2ea8fc8f.tar.gz | |
** See bug #311639.
2005-08-08 Not Zed <NotZed@Ximian.com>
** See bug #311639.
* camel-mh-store.c (folders_update): add a rename mode, fix
callers.
(folders_scan): pass top to folder_info_build, otherwise
get_folder_info doesn't work right. Fix the check for subfolder
test.
| -rw-r--r-- | camel/providers/local/ChangeLog | 10 | ||||
| -rw-r--r-- | camel/providers/local/camel-mh-store.c | 28 |
2 files changed, 30 insertions, 8 deletions
diff --git a/camel/providers/local/ChangeLog b/camel/providers/local/ChangeLog index 53b86e847..673016d94 100644 --- a/camel/providers/local/ChangeLog +++ b/camel/providers/local/ChangeLog @@ -1,3 +1,13 @@ +2005-08-08 Not Zed <NotZed@Ximian.com> + + ** See bug #311639. + + * camel-mh-store.c (folders_update): add a rename mode, fix + callers. + (folders_scan): pass top to folder_info_build, otherwise + get_folder_info doesn't work right. Fix the check for subfolder + test. + 2005-06-08 Not Zed <NotZed@Ximian.com> ** See bug #303225 diff --git a/camel/providers/local/camel-mh-store.c b/camel/providers/local/camel-mh-store.c index 03b6db92b..36325b9ac 100644 --- a/camel/providers/local/camel-mh-store.c +++ b/camel/providers/local/camel-mh-store.c @@ -108,14 +108,16 @@ enum { UPDATE_NONE, UPDATE_ADD, UPDATE_REMOVE, + UPDATE_RENAME, }; /* update the .folders file if it exists, or create it if it doesn't */ static void -folders_update(const char *root, const char *folder, int mode) +folders_update(const char *root, int mode, const char *folder, const char *new) { char *tmp, *tmpnew, *line = NULL; CamelStream *stream, *in = NULL, *out = NULL; + int flen = strlen(folder); tmpnew = g_alloca (strlen (root) + 16); sprintf (tmpnew, "%s.folders~", root); @@ -145,6 +147,16 @@ folders_update(const char *root, const char *folder, int mode) if (strcmp(line, folder) == 0) copy = FALSE; break; + case UPDATE_RENAME: + if (strncmp(line, folder, flen) == 0 + && (line[flen] == 0 || line[flen] == '/')) { + if (camel_stream_write(out, new, strlen(new)) == -1 + || camel_stream_write(out, line+flen, strlen(line)-flen) == -1 + || camel_stream_write(out, "\n", 1) == -1) + goto fail; + copy = FALSE; + } + break; case UPDATE_ADD: { int cmp = strcmp(line, folder); @@ -226,7 +238,7 @@ get_folder(CamelStore * store, const char *folder_name, guint32 flags, CamelExce /* add to .folders if we are supposed to */ /* FIXME: throw exception on error */ if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS) - folders_update(((CamelLocalStore *)store)->toplevel_dir, folder_name, UPDATE_ADD); + folders_update(((CamelLocalStore *)store)->toplevel_dir, UPDATE_ADD, folder_name, NULL); } else if (!S_ISDIR(st.st_mode)) { camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER, _("Cannot get folder `%s': not a directory."), folder_name); @@ -267,7 +279,7 @@ static void delete_folder(CamelStore * store, const char *folder_name, CamelExce /* remove from .folders if we are supposed to */ if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS) - folders_update(((CamelLocalStore *)store)->toplevel_dir, folder_name, UPDATE_REMOVE); + folders_update(((CamelLocalStore *)store)->toplevel_dir, UPDATE_REMOVE, folder_name, NULL); /* and remove metadata */ ((CamelStoreClass *)parent_class)->delete_folder(store, folder_name, ex); @@ -288,8 +300,7 @@ rename_folder(CamelStore *store, const char *old, const char *new, CamelExceptio if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS) { /* yeah this is messy, but so is mh! */ - folders_update(((CamelLocalStore *)store)->toplevel_dir, new, UPDATE_ADD); - folders_update(((CamelLocalStore *)store)->toplevel_dir, old, UPDATE_REMOVE); + folders_update(((CamelLocalStore *)store)->toplevel_dir, UPDATE_RENAME, old, new); } } @@ -482,8 +493,9 @@ folders_scan(CamelStore *store, CamelURL *url, const char *root, const char *top if (top && top[0]) { int toplen = strlen(top); - /* check is subdir */ - if (strncmp(top, line, len) != 0) + /* check is dir or subdir */ + if (strncmp(top, line, toplen) != 0 + || (line[toplen] != 0 && line[toplen] != '/')) continue; /* check is not sub-subdir if not recursive */ @@ -508,7 +520,7 @@ folders_scan(CamelStore *store, CamelURL *url, const char *root, const char *top } if (folders->len) - *fip = camel_folder_info_build(folders, NULL, '/', TRUE); + *fip = camel_folder_info_build(folders, top, '/', TRUE); g_ptr_array_free(folders, TRUE); g_hash_table_foreach(visited, (GHFunc)g_free, NULL); |
