SL-20181 Dupplicate prevention for forced fetches

Might be better to have a separate set of states for 'fetched children'
or 'all children complete' inside the folder itself.
master
Andrey Kleshchev 2023-11-28 21:42:13 +02:00 committed by akleshchev
parent f4307bed26
commit f394d675a7
2 changed files with 39 additions and 6 deletions

View File

@ -358,8 +358,22 @@ void LLInventoryModelBackgroundFetch::scheduleFolderFetch(const LLUUID& cat_id,
{
mBackgroundFetchActive = true;
// Specific folder requests go to front of queue.
mFetchFolderQueue.push_front(FetchQueueInfo(cat_id, forced ? FT_FORCED : FT_DEFAULT));
if (forced)
{
// check if already requested
if (mForceFetchSet.find(cat_id) != mForceFetchSet.end())
{
mForceFetchSet.insert(cat_id);
mFetchItemQueue.push_front(FetchQueueInfo(cat_id, FT_FORCED));
}
}
else
{
// Specific folder requests go to front of queue.
// version presence acts as dupplicate prevention for normal fetches
mFetchItemQueue.push_front(FetchQueueInfo(cat_id, FT_DEFAULT));
}
gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
}
}
@ -369,8 +383,21 @@ void LLInventoryModelBackgroundFetch::scheduleItemFetch(const LLUUID& item_id, b
if (mFetchItemQueue.empty() || mFetchItemQueue.front().mUUID != item_id)
{
mBackgroundFetchActive = true;
if (forced)
{
// check if already requested
if (mForceFetchSet.find(item_id)!= mForceFetchSet.end())
{
mForceFetchSet.insert(item_id);
mFetchItemQueue.push_front(FetchQueueInfo(item_id, FT_FORCED, false));
}
}
else
{
// 'isFinished' being set acts as dupplicate prevention for normal fetches
mFetchItemQueue.push_front(FetchQueueInfo(item_id, FT_DEFAULT, false));
}
mFetchItemQueue.push_front(FetchQueueInfo(item_id, forced ? FT_FORCED : FT_DEFAULT, false));
gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
}
}
@ -846,10 +873,10 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc
mExpectedFolderIds.push_back(cat_id);
EFetchType type = fetch_info.mFetchType;
LLUUID cat_id = cat->getUUID();
AISAPI::completion_t cb = [cat_id , type](const LLUUID& response_id)
LLUUID cat_cb_id = cat_id;
AISAPI::completion_t cb = [cat_cb_id, type](const LLUUID& response_id)
{
LLInventoryModelBackgroundFetch::instance().onAISFolderCalback(cat_id , response_id , type);
LLInventoryModelBackgroundFetch::instance().onAISFolderCalback(cat_cb_id, response_id , type);
};
AISAPI::ITEM_TYPE item_type = AISAPI::INVENTORY;
@ -908,6 +935,11 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc
AISAPI::FetchItem(fetch_info.mUUID, AISAPI::INVENTORY, ais_simple_item_callback);
}
}
if (fetch_info.mFetchType == FT_FORCED)
{
mForceFetchSet.erase(fetch_info.mUUID);
}
}
// Bundle up a bunch of requests to send all at once.

View File

@ -129,6 +129,7 @@ private:
F32 mMinTimeBetweenFetches;
fetch_queue_t mFetchFolderQueue;
fetch_queue_t mFetchItemQueue;
uuid_set_t mForceFetchSet;
std::list<LLUUID> mExpectedFolderIds; // for debug, should this track time?
};