dovecot-1.0: If INBOX is a substring of already added path, don'...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Sep 9 05:06:24 EEST 2007
details: http://hg.dovecot.org/dovecot-1.0/rev/a3f2f00cbd7c
changeset: 5395:a3f2f00cbd7c
user: Timo Sirainen <tss at iki.fi>
date: Sun Sep 09 05:04:39 2007 +0300
description:
If INBOX is a substring of already added path, don't assert-crash. Also
fixed handling cases where parent directory was added while its multiple
children were already added (probably never happened).
diffstat:
1 file changed, 16 insertions(+), 13 deletions(-)
src/plugins/quota/quota-dirsize.c | 29 ++++++++++++++++-------------
diffs (45 lines):
diff -r 798963ca1f6f -r a3f2f00cbd7c src/plugins/quota/quota-dirsize.c
--- a/src/plugins/quota/quota-dirsize.c Sun Sep 09 03:52:11 2007 +0300
+++ b/src/plugins/quota/quota-dirsize.c Sun Sep 09 05:04:39 2007 +0300
@@ -166,25 +166,28 @@ static void quota_count_path_add(array_t
{
ARRAY_SET_TYPE(paths, struct quota_count_path);
struct quota_count_path *count_path;
- unsigned int i, count;
-
+ unsigned int i, count, path_len;
+
+ path_len = strlen(path);
count_path = array_get_modifyable(paths, &count);
- for (i = 0; i < count; i++) {
+ for (i = 0; i < count; ) {
if (strncmp(count_path[i].path, path,
strlen(count_path[i].path)) == 0) {
/* this path is already being counted */
return;
}
- if (strncmp(count_path[i].path, path, strlen(path)) == 0) {
- /* the new path contains the existing path */
- i_assert(!is_file);
- count_path += i;
- break;
- }
- }
-
- if (i == count)
- count_path = array_append_space(paths);
+ if (strncmp(count_path[i].path, path, path_len) == 0 &&
+ count_path[i].path[path_len] == '/') {
+ /* the new path contains the existing path.
+ drop it and see if there are more to drop. */
+ array_delete(paths, i, 1);
+ count_path = array_get_modifyable(paths, &count);
+ } else {
+ i++;
+ }
+ }
+
+ count_path = array_append_space(paths);
count_path->path = t_strdup(path);
count_path->is_file = is_file;
}
More information about the dovecot-cvs
mailing list