fs-dict.c (dovecot-2.3.16) | : | fs-dict.c (dovecot-2.3.17) | ||
---|---|---|---|---|
skipping to change at line 75 | skipping to change at line 75 | |||
fs->encoding = FS_DICT_VALUE_ENCODING_HEX; | fs->encoding = FS_DICT_VALUE_ENCODING_HEX; | |||
else if (strcmp(encoding_str, "base64") == 0) | else if (strcmp(encoding_str, "base64") == 0) | |||
fs->encoding = FS_DICT_VALUE_ENCODING_BASE64; | fs->encoding = FS_DICT_VALUE_ENCODING_BASE64; | |||
else { | else { | |||
*error_r = t_strdup_printf("Unknown value encoding '%s'", | *error_r = t_strdup_printf("Unknown value encoding '%s'", | |||
encoding_str); | encoding_str); | |||
return -1; | return -1; | |||
} | } | |||
i_zero(&dict_set); | i_zero(&dict_set); | |||
dict_set.username = set->username; | ||||
dict_set.base_dir = set->base_dir; | dict_set.base_dir = set->base_dir; | |||
dict_set.event_parent = set->event_parent; | dict_set.event_parent = set->event_parent; | |||
if (dict_init(p, &dict_set, &fs->dict, &error) < 0) { | if (dict_init(p, &dict_set, &fs->dict, &error) < 0) { | |||
*error_r = t_strdup_printf("dict_init(%s) failed: %s", | *error_r = t_strdup_printf("dict_init(%s) failed: %s", | |||
args, error); | args, error); | |||
return -1; | return -1; | |||
} | } | |||
return 0; | return 0; | |||
} | } | |||
skipping to change at line 160 | skipping to change at line 159 | |||
static int fs_dict_lookup(struct dict_fs_file *file) | static int fs_dict_lookup(struct dict_fs_file *file) | |||
{ | { | |||
struct dict_fs *fs = (struct dict_fs *)file->file.fs; | struct dict_fs *fs = (struct dict_fs *)file->file.fs; | |||
const char *error; | const char *error; | |||
int ret; | int ret; | |||
if (file->value != NULL) | if (file->value != NULL) | |||
return 0; | return 0; | |||
ret = dict_lookup(fs->dict, file->pool, file->key, &file->value, &error); | struct dict_op_settings set = { | |||
.username = file->file.fs->username, | ||||
}; | ||||
ret = dict_lookup(fs->dict, &set, file->pool, file->key, &file->value, &e | ||||
rror); | ||||
if (ret > 0) | if (ret > 0) | |||
return 0; | return 0; | |||
else if (ret < 0) { | else if (ret < 0) { | |||
fs_set_error(file->file.event, EIO, | fs_set_error(file->file.event, EIO, | |||
"dict_lookup(%s) failed: %s", file->key, error); | "dict_lookup(%s) failed: %s", file->key, error); | |||
return -1; | return -1; | |||
} else { | } else { | |||
fs_set_error(file->file.event, ENOENT, | fs_set_error(file->file.event, ENOENT, | |||
"Dict key %s doesn't exist", file->key); | "Dict key %s doesn't exist", file->key); | |||
return -1; | return -1; | |||
skipping to change at line 224 | skipping to change at line 226 | |||
{ | { | |||
struct dict_fs_file *file = (struct dict_fs_file *)_file; | struct dict_fs_file *file = (struct dict_fs_file *)_file; | |||
struct dict_fs *fs = (struct dict_fs *)_file->fs; | struct dict_fs *fs = (struct dict_fs *)_file->fs; | |||
struct dict_transaction_context *trans; | struct dict_transaction_context *trans; | |||
const char *error; | const char *error; | |||
o_stream_destroy(&_file->output); | o_stream_destroy(&_file->output); | |||
if (!success) | if (!success) | |||
return -1; | return -1; | |||
struct dict_op_settings set = { | ||||
.username = _file->fs->username, | ||||
}; | ||||
fs_dict_write_rename_if_needed(file); | fs_dict_write_rename_if_needed(file); | |||
trans = dict_transaction_begin(fs->dict); | trans = dict_transaction_begin(fs->dict, &set); | |||
switch (fs->encoding) { | switch (fs->encoding) { | |||
case FS_DICT_VALUE_ENCODING_RAW: | case FS_DICT_VALUE_ENCODING_RAW: | |||
dict_set(trans, file->key, str_c(file->write_buffer)); | dict_set(trans, file->key, str_c(file->write_buffer)); | |||
break; | break; | |||
case FS_DICT_VALUE_ENCODING_HEX: { | case FS_DICT_VALUE_ENCODING_HEX: { | |||
string_t *hex = t_str_new(file->write_buffer->used * 2 + 1); | string_t *hex = t_str_new(file->write_buffer->used * 2 + 1); | |||
binary_to_hex_append(hex, file->write_buffer->data, | binary_to_hex_append(hex, file->write_buffer->data, | |||
file->write_buffer->used); | file->write_buffer->used); | |||
dict_set(trans, file->key, str_c(hex)); | dict_set(trans, file->key, str_c(hex)); | |||
break; | break; | |||
skipping to change at line 273 | skipping to change at line 278 | |||
return 0; | return 0; | |||
} | } | |||
static int fs_dict_delete(struct fs_file *_file) | static int fs_dict_delete(struct fs_file *_file) | |||
{ | { | |||
struct dict_fs_file *file = (struct dict_fs_file *)_file; | struct dict_fs_file *file = (struct dict_fs_file *)_file; | |||
struct dict_fs *fs = (struct dict_fs *)_file->fs; | struct dict_fs *fs = (struct dict_fs *)_file->fs; | |||
struct dict_transaction_context *trans; | struct dict_transaction_context *trans; | |||
const char *error; | const char *error; | |||
trans = dict_transaction_begin(fs->dict); | struct dict_op_settings set = { | |||
.username = fs->fs.username, | ||||
}; | ||||
trans = dict_transaction_begin(fs->dict, &set); | ||||
dict_unset(trans, file->key); | dict_unset(trans, file->key); | |||
if (dict_transaction_commit(&trans, &error) < 0) { | if (dict_transaction_commit(&trans, &error) < 0) { | |||
fs_set_error(_file->event, EIO, | fs_set_error(_file->event, EIO, | |||
"Dict transaction commit failed: %s", error); | "Dict transaction commit failed: %s", error); | |||
return -1; | return -1; | |||
} | } | |||
return 0; | return 0; | |||
} | } | |||
static struct fs_iter *fs_dict_iter_alloc(void) | static struct fs_iter *fs_dict_iter_alloc(void) | |||
skipping to change at line 299 | skipping to change at line 307 | |||
static void | static void | |||
fs_dict_iter_init(struct fs_iter *_iter, const char *path, | fs_dict_iter_init(struct fs_iter *_iter, const char *path, | |||
enum fs_iter_flags flags ATTR_UNUSED) | enum fs_iter_flags flags ATTR_UNUSED) | |||
{ | { | |||
struct dict_fs_iter *iter = (struct dict_fs_iter *)_iter; | struct dict_fs_iter *iter = (struct dict_fs_iter *)_iter; | |||
struct dict_fs *fs = (struct dict_fs *)_iter->fs; | struct dict_fs *fs = (struct dict_fs *)_iter->fs; | |||
if (fs->path_prefix != NULL) | if (fs->path_prefix != NULL) | |||
path = t_strconcat(fs->path_prefix, path, NULL); | path = t_strconcat(fs->path_prefix, path, NULL); | |||
iter->dict_iter = dict_iterate_init(fs->dict, path, 0); | struct dict_op_settings set = { | |||
.username = iter->iter.fs->username, | ||||
}; | ||||
iter->dict_iter = dict_iterate_init(fs->dict, &set, path, 0); | ||||
} | } | |||
static const char *fs_dict_iter_next(struct fs_iter *_iter) | static const char *fs_dict_iter_next(struct fs_iter *_iter) | |||
{ | { | |||
struct dict_fs_iter *iter = (struct dict_fs_iter *)_iter; | struct dict_fs_iter *iter = (struct dict_fs_iter *)_iter; | |||
const char *key, *value; | const char *key, *value; | |||
if (!dict_iterate(iter->dict_iter, &key, &value)) | if (!dict_iterate(iter->dict_iter, &key, &value)) | |||
return NULL; | return NULL; | |||
return key; | return key; | |||
End of changes. 6 change blocks. | ||||
5 lines changed or deleted | 17 lines changed or added |