Skip to content

Commit

Permalink
Feature/check for empty oid (#372)
Browse files Browse the repository at this point in the history
* check for empty oid

* 0.0.52-SNAPSHOT

* check get_oid()->empty() or nullptr

* always set rbox->last_seq

* always set rbox->last_seq when allow_rbox_mail

* version 0.0.52
  • Loading branch information
jrse authored Feb 27, 2023
1 parent 727046c commit 4700f2f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 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.52](https://github.com/ceph-dovecot/dovecot-ceph-plugin/tree/0.0.52) (2023-02-27)
- fix: some problems with virtual box and Spica

## [0.0.51](https://github.com/ceph-dovecot/dovecot-ceph-plugin/tree/0.0.51) (2023-02-09)
- fix: not escaped % in i_warning.

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
AC_PREREQ([2.59])


AC_INIT([dovecot-ceph-plugin], [0.0.51], [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.52], [https://github.com/ceph-dovecot/dovecot-ceph-plugin/issues/new], ,[https://github.com/ceph-dovecot/dovecot-ceph-plugin])



Expand Down
2 changes: 1 addition & 1 deletion rpm/dovecot-ceph-plugin.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Name: dovecot-ceph-plugin
Summary: Dovecot Ceph RADOS plugins

Version: 0.0.51
Version: 0.0.52


Release: 0%{?dist}
Expand Down
18 changes: 13 additions & 5 deletions src/storage-rbox/rbox-mail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ static int rbox_mail_metadata_get(struct rbox_mail *rmail, enum rbox_metadata_ke
// make sure that mail_object is initialized,
// else create and load guid from index.
rmail->rados_mail = r_storage->s->alloc_rados_mail();
rmail->last_seq = -1;
}
if(rmail->rados_mail->get_oid() == nullptr || rmail->rados_mail->get_oid()->empty()){
if (rbox_get_index_record(mail) < 0) {
i_error("Error rbox_get_index_record uid(%d)", mail->uid);
FUNC_END();
Expand All @@ -155,9 +158,7 @@ static int rbox_mail_metadata_get(struct rbox_mail *rmail, enum rbox_metadata_ke
int ret_load_metadata = r_storage->ms->get_storage()->load_metadata(rmail->rados_mail);
if (ret_load_metadata < 0) {
std::string metadata_key = librmb::rbox_metadata_key_to_char(key);
if (ret_load_metadata == -ENOENT) {
//i_debug("Errorcode: process %d returned with %d cannot get x_attr(%s,%c) from rados_object: %s",getpid(), ret_load_metadata,
// metadata_key.c_str(), key, rmail->rados_mail != NULL ? rmail->rados_mail->to_string(" ").c_str() : " no rados_mail");
if (ret_load_metadata == -ENOENT) {
rbox_mail_set_expunged(rmail);
}
else {
Expand Down Expand Up @@ -201,6 +202,7 @@ int rbox_mail_get_received_date(struct mail *_mail, time_t *date_r) {
// else create and load guid from index.
struct rbox_storage *r_storage = (struct rbox_storage *)_mail->box->storage;
rmail->rados_mail = r_storage->s->alloc_rados_mail();
rmail->last_seq = -1;
if (rbox_get_index_record(_mail) < 0) {
i_error("Error rbox_get_index uid(%d)", _mail->uid);
FUNC_END();
Expand Down Expand Up @@ -272,6 +274,7 @@ static int rbox_mail_get_save_date(struct mail *_mail, time_t *date_r) {
// else create and load guid from index.
struct rbox_storage *r_storage = (struct rbox_storage *)_mail->box->storage;
rmail->rados_mail = r_storage->s->alloc_rados_mail();
rmail->last_seq = -1;
if (rbox_get_index_record(_mail) < 0) {
i_error("Error rbox_get_index uid(%d)", _mail->uid);
FUNC_END();
Expand Down Expand Up @@ -487,8 +490,13 @@ static int rbox_mail_get_stream(struct mail *_mail, bool get_body ATTR_UNUSED, s
if (rmail->rados_mail == nullptr) {
// make sure that mail_object is initialized,
// else create and load guid from index.
rmail->rados_mail = rados_storage->alloc_rados_mail();
if (rbox_get_index_record(_mail) < 0) {
rmail->rados_mail = rados_storage->alloc_rados_mail();
rmail->last_seq = -1;
}

if(rmail->rados_mail->get_oid() == nullptr || rmail->rados_mail->get_oid()->empty()){
//reload get index_record.
if (rbox_get_index_record(_mail) < 0) {
i_error("Error rbox_get_index uid(%d)", _mail->uid);
FUNC_END();
return -1;
Expand Down

0 comments on commit 4700f2f

Please sign in to comment.