SL-18003 Bulk fetch some items by fetching whole folder

meow-7.2.2
Andrey Kleshchev 2023-03-26 13:44:50 +03:00
parent c9d9f1c54e
commit 6fd7427c57
6 changed files with 75 additions and 4 deletions

View File

@ -373,7 +373,6 @@ void AISAPI::UpdateItem(const LLUUID &itemId, const LLSD &updates, completion_t
/*static*/
void AISAPI::FetchItem(const LLUUID &itemId, ITEM_TYPE type, completion_t callback)
{
std::string cap;
cap = (type == INVENTORY) ? getInvCap() : getLibCap();
@ -859,6 +858,7 @@ void AISUpdate::parseItem(const LLSD& item_map)
{
mItemsCreated[item_id] = new_item;
mCatDescendentDeltas[new_item->getParentUUID()]++;
new_item->setComplete(true);
}
}
else
@ -893,6 +893,7 @@ void AISUpdate::parseLink(const LLSD& link_map)
//LL_DEBUGS("Inventory") << "creating link from llsd: " << ll_pretty_print_sd(link_map) << LL_ENDL;
mItemsCreated[item_id] = new_link;
mCatDescendentDeltas[parent_id];
new_link->setComplete(true);
}
else if (curr_link)
{
@ -913,6 +914,7 @@ void AISUpdate::parseLink(const LLSD& link_map)
//LL_DEBUGS("Inventory") << "creating link from llsd: " << ll_pretty_print_sd(link_map) << LL_ENDL;
mItemsCreated[item_id] = new_link;
mCatDescendentDeltas[parent_id]++;
new_link->setComplete(true);
}
}
else

View File

@ -4385,6 +4385,70 @@ public:
~CallAfterCategoryFetchStage1()
{
}
/*virtual*/ void startFetch()
{
bool ais3 = AISAPI::isAvailable();
for (uuid_vec_t::const_iterator it = mIDs.begin(); it != mIDs.end(); ++it)
{
LLViewerInventoryCategory* cat = gInventory.getCategory(*it);
if (!cat) continue;
if (!isCategoryComplete(cat))
{
// CHECK IT: isCategoryComplete() checks both version and descendant count but
// fetch() only works for Unknown version and doesn't care about descentants,
// as result fetch won't start and folder will potentially get stuck as
// incomplete in observer.
// Likely either both should use only version or both should check descendants.
cat->fetch(); //blindly fetch it without seeing if anything else is fetching it.
mIncomplete.push_back(*it); //Add to list of things being downloaded for this observer.
}
else if (ais3)
{
LLInventoryModel::cat_array_t* cats;
LLInventoryModel::item_array_t* items;
gInventory.getDirectDescendentsOf(cat->getUUID(), cats, items);
if (items)
{
S32 complete_count = 0;
S32 incomplete_count = 0;
for (LLInventoryModel::item_array_t::const_iterator it = items->begin(); it < items->end(); ++it)
{
if (!(*it)->isFinished())
{
incomplete_count++;
}
else
{
complete_count++;
}
}
// AIS can fetch couple items, but if there
// is more than a dozen it will be very slow
// it's faster to get whole folder in such case
const S32 MAX_INDIVIDUAL_FETCH = 10;
if (incomplete_count > MAX_INDIVIDUAL_FETCH
|| (incomplete_count > 1 && complete_count == 0))
{
// To prevent premature removal from mIncomplete and
// since we are doing a full refetch anyway, mark unknown
cat->setVersion(LLViewerInventoryCategory::VERSION_UNKNOWN);
LLInventoryModelBackgroundFetch::instance().start(*it, false);
mIncomplete.push_back(*it);
}
else
{
// let stage2 handle incomplete ones
mComplete.push_back(*it);
}
}
}
else
{
mComplete.push_back(*it);
}
}
}
virtual void done()
{
if (mComplete.size() <= 0)

View File

@ -31,8 +31,9 @@
#include "llagent.h"
#include "llappviewer.h"
#include "llcallbacklist.h"
#include "llinventorypanel.h"
#include "llinventorymodel.h"
#include "llinventoryobserver.h"
#include "llinventorypanel.h"
#include "llstartup.h"
#include "llviewercontrol.h"
#include "llviewerinventory.h"
@ -349,6 +350,9 @@ void LLInventoryModelBackgroundFetch::setAllFoldersFetched()
//LL_INFOS(LOG_INV) << "All folders fetched, validating" << LL_ENDL;
//gInventory.validate();
gInventory.addChangedMask(LLInventoryObserver::INTERNAL, gInventory.getRootFolderID());
gInventory.addChangedMask(LLInventoryObserver::INTERNAL, gInventory.getLibraryRootFolderID());
// For now only informs about initial fetch being done
mAllFoldersFetchedSignal();
}

View File

@ -40,6 +40,7 @@
#include "llaisapi.h"
#include "llfloater.h"
#include "llfocusmgr.h"
#include "llinventorymodelbackgroundfetch.h"
#include "llinventorybridge.h"
#include "llinventoryfunctions.h"
#include "llinventorymodel.h"

View File

@ -126,7 +126,7 @@ public:
LLInventoryFetchDescendentsObserver(const LLUUID& cat_id = LLUUID::null);
LLInventoryFetchDescendentsObserver(const uuid_vec_t& cat_ids);
/*virtual*/ void startFetch();
virtual void startFetch();
/*virtual*/ void changed(U32 mask);
protected:
BOOL isCategoryComplete(const LLViewerInventoryCategory* cat) const;

View File

@ -671,7 +671,7 @@ bool LLViewerInventoryCategory::fetch()
}
if (!url.empty() || AISAPI::isAvailable())
{
LLInventoryModelBackgroundFetch::instance().start(mUUID, false);
LLInventoryModelBackgroundFetch::instance().start(mUUID, false);
}
return true;
}