Mercurial > dovecot > core-2.2
changeset 6362:ad46cb956a0a HEAD
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).
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 09 Sep 2007 05:06:17 +0300 |
parents | 7f6c99dc1f17 |
children | 2b6e69bda3ec |
files | src/plugins/quota/quota-dirsize.c |
diffstat | 1 files changed, 12 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/quota/quota-dirsize.c Sun Sep 09 04:42:42 2007 +0300 +++ b/src/plugins/quota/quota-dirsize.c Sun Sep 09 05:06:17 2007 +0300 @@ -119,25 +119,28 @@ const char *path, bool is_file) { struct quota_count_path *count_path; - unsigned int i, count; + unsigned int i, count, path_len; + path_len = strlen(path); count_path = array_get_modifiable(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 has already been 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 (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_modifiable(paths, &count); + } else { + i++; } } - if (i == count) - count_path = array_append_space(paths); + count_path = array_append_space(paths); count_path->path = t_strdup(path); count_path->is_file = is_file; }