Skip to content

Commit

Permalink
#130 new unit test, to evaluate resync behavior (different xattribut …
Browse files Browse the repository at this point in the history
…MailboxGuid 'M' same uid)
  • Loading branch information
jrse committed Mar 27, 2018
1 parent 0831efa commit fadc3b2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/storage-rbox/rbox-sync-rebuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,28 @@ int rbox_sync_index_rebuild(struct index_rebuild_context *ctx, librados::NObject
// find all objects with x attr M = mailbox_guid
// if non is found : set mailbox_deleted and mail_storage_set_critical...

// it is required to check for duplicat uids,
// because if user moved / copied mails from mailbox to sub-mailbox,
// uid may stay the same (depends on configuration).
std::vector<std::string> uids;

int found = 0;
int ret = 0;
while (iter != librados::NObjectIterator::__EndObjectIterator) {
std::map<std::string, ceph::bufferlist> attrset;
librmb::RadosMailObject mail_object;
mail_object.set_oid((*iter).get_oid());

int retx = r_storage->ms->get_storage()->load_metadata(&mail_object);


/*std::string uid = mail_object->get_metadata(librmb::RBOX_METADATA_MAIL_UID);
if(std::find(vector.begin(), vector.end(), uid) != vector.end(){
uids.put_back(uid);
}else{
// ups we have a duplicate!!!
}
*/
if (retx >= 0) {
ret = rbox_sync_add_object(ctx, (*iter).get_oid(), &mail_object);
if (ret < 0) {
Expand Down
5 changes: 5 additions & 0 deletions src/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ it_test_sync_rbox_2_SOURCES = sync-rbox/it_test_sync_rbox_2.cpp sync-rbox/TestCa
it_test_sync_rbox_2_CPPFLAGS = $(AM_CPPFLAGS) $(LIBDOVECOT_INCLUDE)
it_test_sync_rbox_2_LDADD = $(storage_shlibs) $(gtest_shlibs)

TESTS += it_test_sync_rbox_duplicate_uid
it_test_sync_rbox_duplicate_uid_SOURCES = sync-rbox/it_test_sync_rbox_duplicate_uid.cpp sync-rbox/TestCase.cpp sync-rbox/TestCase.h test-utils/it_utils.cpp test-utils/it_utils.h
it_test_sync_rbox_duplicate_uid_CPPFLAGS = $(AM_CPPFLAGS) $(LIBDOVECOT_INCLUDE)
it_test_sync_rbox_duplicate_uid_LDADD = $(storage_shlibs) $(gtest_shlibs)

endif

check_PROGRAMS = $(TESTS)
Expand Down

0 comments on commit fadc3b2

Please sign in to comment.