Skip to content

Commit

Permalink
Develop (#288)
Browse files Browse the repository at this point in the history
* 217: fix unused code.

* 217: unused code and warning

* disabled man pages for rmb

* Bugfix/283 virtual mailbox fetch metadata (#284)

* Develop (#282)

* 217: fix unused code.

* 217: unused code and warning

* disabled man pages for rmb

* #283: fetch metadata for mails in virtual mailbox

* #283: fix metadata date.saved. date.received virtual mailbox

* #283: version

* Feature/286 use guid from UUID string (#287)

* #256: use guid_128_from_uuid_string instead of guid_128_from_string, to support older uuid formats like RECORD or MICROSOFT, always use compact for printing

* version 0.0.25 preparations

* #286: build issue

* merge

* version

* #286: prefere cached mail guid.

* #286: determine if uuid has - hyphon, if true preseve it.

* fix non void return
  • Loading branch information
jrse authored Mar 1, 2022
1 parent 1171370 commit b4b6a36
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Change Log
## [0.0.26](https://github.com/ceph-dovecot/dovecot-ceph-plugin/tree/0.0.25) (2022-02-28)

- support deprecated uuid format RECORD and MICROSOFT

## [0.0.25](https://github.com/ceph-dovecot/dovecot-ceph-plugin/tree/0.0.25) (2022-02-23)

- virtual_mailbox: bugfix fetch fields (x-guid, date.saved..)
Expand Down
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

AC_PREREQ([2.59])

AC_INIT([dovecot-ceph-plugin], [0.0.25], [https://github.com/ceph-dovecot/dovecot-ceph-plugin/issues/new], ,[https://github.com/ceph-dovecot/dovecot-ceph-plugin])
AC_INIT([dovecot-ceph-plugin], [0.0.26], [https://github.com/ceph-dovecot/dovecot-ceph-plugin/issues/new], ,[https://github.com/ceph-dovecot/dovecot-ceph-plugin])

AC_CONFIG_AUX_DIR([.])
AC_CONFIG_SRCDIR([src])
AC_CONFIG_MACRO_DIR([m4])
Expand Down
3 changes: 2 additions & 1 deletion rpm/dovecot-ceph-plugin.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

Name: dovecot-ceph-plugin
Summary: Dovecot Ceph RADOS plugins
Version: 0.0.25
Version: 0.0.26

Release: 0%{?dist}
URL: https://github.com/ceph-dovecot/dovecot-ceph-plugin
Group: Productivity/Networking/Email/Servers
Expand Down
4 changes: 3 additions & 1 deletion src/librmb/rados-mail.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ class RadosMail {
int get_num_active_op() { return active_op; }
string to_string(const string& padding);
void add_metadata(const RadosMetadata& metadata) { attrset[metadata.key] = metadata.bl; }

bool is_deprecated_uid() {return deprecated_uid;}
void set_deprecated_uid(bool deprecated_uid_) {deprecated_uid = deprecated_uid_;}
/*!
* Some metadata isn't saved as xattribute (default). To access those, get_extended_metadata can
* be used.
Expand Down Expand Up @@ -121,6 +122,7 @@ class RadosMail {
map<string, ceph::bufferlist> extended_attrset;
bool valid;
bool index_ref;
bool deprecated_uid;
};

} // namespace librmb
Expand Down
6 changes: 5 additions & 1 deletion src/storage-rbox/doveadm-rbox-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,11 @@ static int restore_index_entry(struct mail_user *user, const char *mailbox_name,
struct rbox_save_context *r_ctx = (struct rbox_save_context *)save_ctx;

guid_128_t mail_guid, mail_oid;
guid_128_from_string(str_mail_guid.c_str(), mail_guid);

if(guid_128_from_uuid_string(str_mail_guid.c_str(), mail_guid)< 0){
i_error("guid_128 xattr_guid string '%s'", str_mail_guid.c_str());
return -1;
}
guid_128_from_string(str_mail_oid.c_str(), mail_oid);

memcpy(rec.guid, mail_guid, sizeof(mail_guid));
Expand Down
15 changes: 11 additions & 4 deletions src/storage-rbox/rbox-mail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ int rbox_get_guid_metadata(struct rbox_mail *mail, const char **value_r) {
struct index_mail *imail = &mail->imail;
string_t *str = str_new(imail->mail.data_pool, 64);
str_truncate(str, 0);
str_append(str, guid_128_to_string(mail->index_guid));
// always provide uuid compact format.
str_append(str, guid_128_to_uuid_string(mail->index_guid, FORMAT_COMPACT));
*value_r = str_c(str);
return 0;
}
Expand All @@ -542,7 +543,10 @@ int rbox_get_guid_metadata(struct rbox_mail *mail, const char **value_r) {
}

// restore the index extension header quietly.
guid_128_from_string(*value_r, mail->index_guid);
if(guid_128_from_uuid_string(*value_r, mail->index_guid)< 0){
i_error("guid_128 xattr_guid string '%s'", *value_r);
return -1;
}
struct index_mail *imail = &mail->imail;
struct mail *_mail = (struct mail *)mail;
struct rbox_mailbox *mbox = (struct rbox_mailbox *)_mail->box;
Expand Down Expand Up @@ -623,8 +627,11 @@ static int rbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field
used. */
switch (field) {
case MAIL_FETCH_GUID:
return rbox_get_guid_metadata(mail, value_r);
// return rbox_get_cached_metadata(mail, rbox_metadata_key::RBOX_METADATA_GUID, MAIL_CACHE_GUID, value_r);
ret = rbox_get_cached_metadata(mail, rbox_metadata_key::RBOX_METADATA_GUID, MAIL_CACHE_GUID, value_r);
if( ret < 0){
return rbox_get_guid_metadata(mail, value_r);
}
return ret;
case MAIL_FETCH_UIDL_BACKEND:
if (!rbox_header_have_flag(_mail->box, mbox->hdr_ext_id, offsetof(struct rbox_index_header, flags),
RBOX_INDEX_HEADER_FLAG_HAVE_POP3_UIDLS)) {
Expand Down
20 changes: 18 additions & 2 deletions src/storage-rbox/rbox-save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ void setup_mail_object(struct mail_save_context *_ctx) {

if (_ctx->data.guid != NULL) {
string str(_ctx->data.guid);
//#286: use deprecated_flag to save original uuid format to G xattr
if (str.find("-")<str.length()) {
r_ctx->rados_mail->set_deprecated_uid(true);
}
librmb::RadosUtils::find_and_replace(&str, "-", ""); // remove hyphens if they exist
mail_generate_guid_128_hash(str.c_str(), r_ctx->mail_guid);
} else {
Expand Down Expand Up @@ -162,6 +166,10 @@ void rbox_move_index(struct mail_save_context *_ctx, struct mail *src_mail) {

if (_ctx->data.guid != NULL) {
string str(_ctx->data.guid);
//#286: use deprecated_flag to save original uuid format to G xattr
if (str.find("-")<str.length()) {
r_ctx->rados_mail->set_deprecated_uid(true);
}
librmb::RadosUtils::find_and_replace(&str, "-", ""); // remove hyphens if they exist
mail_generate_guid_128_hash(str.c_str(), r_ctx->mail_guid);
} else {
Expand Down Expand Up @@ -288,9 +296,17 @@ static int rbox_save_mail_set_metadata(struct rbox_save_context *r_ctx, librmb::
mail_object->add_metadata(xattr);
}
if (r_storage->config->is_mail_attribute(rbox_metadata_key::RBOX_METADATA_GUID)) {
RadosMetadata xattr(rbox_metadata_key::RBOX_METADATA_GUID, guid_128_to_string(r_ctx->mail_guid));
mail_object->add_metadata(xattr);
//#286: use deprecated_flag to save original uuid format to G xattr
if(!mail_object->is_deprecated_uid()){
RadosMetadata xattr(rbox_metadata_key::RBOX_METADATA_GUID, guid_128_to_string(r_ctx->mail_guid));
mail_object->add_metadata(xattr);
}
else{
RadosMetadata xattr(rbox_metadata_key::RBOX_METADATA_GUID, guid_128_to_uuid_string(r_ctx->mail_guid,FORMAT_RECORD));
mail_object->add_metadata(xattr);
}
}

if (r_storage->config->is_mail_attribute(rbox_metadata_key::RBOX_METADATA_RECEIVED_TIME)) {
RadosMetadata xattr(rbox_metadata_key::RBOX_METADATA_RECEIVED_TIME, mdata->received_date);
mail_object->add_metadata(xattr);
Expand Down
7 changes: 3 additions & 4 deletions src/storage-rbox/rbox-sync-rebuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ int rbox_sync_add_object(struct index_rebuild_context *ctx, const std::string &o
return -1;
}
guid_128_t guid;
if (guid_128_from_string(xattr_guid, guid) < 0) {
i_error("guid_128 xattr_guid string '%s', next_uid(%d)", xattr_guid, next_uid);
FUNC_END();
return -1;
if (guid_128_from_uuid_string(xattr_guid, guid) < 0) {
FUNC_END();
return -1;
}
memcpy(rec.guid, guid, sizeof(guid));
memcpy(rec.oid, oid, sizeof(oid));
Expand Down

0 comments on commit b4b6a36

Please sign in to comment.