diff --git a/src/storage-rbox/rbox-sync-rebuild.cpp b/src/storage-rbox/rbox-sync-rebuild.cpp index bd566fba..394df976 100644 --- a/src/storage-rbox/rbox-sync-rebuild.cpp +++ b/src/storage-rbox/rbox-sync-rebuild.cpp @@ -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 uids; + int found = 0; int ret = 0; while (iter != librados::NObjectIterator::__EndObjectIterator) { std::map 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) { diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index 7db94c23..88c210eb 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -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)