Esempio n. 1
0
OP_STATUS IntersectionIndexGroup::AddIndex(index_gid_t index_id)
{
	if (m_indexes.Contains(index_id))
		return OpStatus::OK;

	Index* index = m_indexer->GetIndexById(index_id);

	if (index)
	{
		RETURN_IF_ERROR(index->PreFetch());
		
		OpINT32Vector all_messages;
		RETURN_IF_ERROR(m_index->GetAllMessages(all_messages));
		for (UINT32 i = 0; i < all_messages.GetCount(); i++)
		{
			if (!index->Contains(all_messages.Get(i)))
			{
				RETURN_IF_ERROR(m_index->RemoveMessage(all_messages.Get(i)));
			}
		}

		RETURN_IF_ERROR(m_indexes.Insert(index_id));
		RETURN_IF_ERROR(index->AddObserver(this));
	}

	return OpStatus::OK;
}
Esempio n. 2
0
/***********************************************************************************
 **
 ** MailRecovery::GhostBuster
 ***********************************************************************************/
OP_STATUS MailRecovery::GhostBuster()
{
    Store* store = g_m2_engine->GetStore();
    // we can only run this if we have loaded all messages!
    if (!store->HasFinishedLoading())
        return OpStatus::OK;

    OpString8 indexes_with_ghosts;
    OpStringC8 log_heading("Ghostbuster");
    OpStatus::Ignore(DesktopFileLogger::Log(m_recovery_log,log_heading,"Started"));
    INT32 num_ghosts = 0;
    Index* current;
    // go through all indexes
    for (INT32 it = -1; (current = g_m2_engine->GetIndexer()->GetRange(0, IndexTypes::LAST, it)) != NULL; )
    {
        OpINT32Vector message_ids;

        if (OpStatus::IsError(current->PreFetch()) || OpStatus::IsError(current->GetAllMessages(message_ids)))
            continue;

        // go through all messages in all indexes
        for (UINT32 nb = 0; nb < message_ids.GetCount(); nb++)
        {
            INT32 message_id = message_ids.Get(nb);
            // check if the message really exists in store
            if (!store->MessageAvailable(message_id))
            {
                // we have a ghost, a message that doesn't exist in store, but exists in an index
                current->RemoveMessage(message_id);
                num_ghosts++;
                indexes_with_ghosts.AppendFormat(" %d",current->GetId());
            }
        }
    }
    OpStatus::Ignore(store->CommitData());
    OpString8 log_text;
    OpStatus::Ignore(log_text.AppendFormat("Finished: Deleted %d ghosts from the following indexes:%s", num_ghosts, indexes_with_ghosts.CStr()));
    OpStatus::Ignore(DesktopFileLogger::Log(m_recovery_log,log_heading,log_text));
    return OpStatus::OK;
}
Esempio n. 3
0
OP_STATUS UnionIndexGroup::AddIndex(index_gid_t index_id)
{
	if (m_indexes.Contains(index_id))
		return OpStatus::OK;

	RETURN_IF_ERROR(m_indexes.Insert(index_id));

	Index* index = m_indexer->GetIndexById(index_id);

	if (index)
	{
		index->PreFetch();
		for (INT32SetIterator it(index->GetIterator()); it; it++)
		{
			RETURN_IF_ERROR(m_index->NewMessage(it.GetData()));
		}

		index->AddObserver(this);

		m_index->ResetUnreadCount();
	}

	return OpStatus::OK;
}