summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-03-26 13:44:50 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-03-26 13:44:50 +0300
commit6fd7427c576ec922b6c670b4ff9381c7cb738b5b (patch)
tree7b63f59194b0b4df02358f3fe4be9950402a8969 /indra
parentc9d9f1c54e104dd0ac670fbac2f4e9e053eea25c (diff)
SL-18003 Bulk fetch some items by fetching whole folder
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llaisapi.cpp4
-rw-r--r--indra/newview/llappearancemgr.cpp64
-rw-r--r--indra/newview/llinventorymodelbackgroundfetch.cpp6
-rw-r--r--indra/newview/llinventoryobserver.cpp1
-rw-r--r--indra/newview/llinventoryobserver.h2
-rw-r--r--indra/newview/llviewerinventory.cpp2
6 files changed, 75 insertions, 4 deletions
diff --git a/indra/newview/llaisapi.cpp b/indra/newview/llaisapi.cpp
index d204a752ec..6a43c901e7 100644
--- a/indra/newview/llaisapi.cpp
+++ b/indra/newview/llaisapi.cpp
@@ -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
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 1de3cef3ba..b36ea1c457 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -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)
diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp
index 023cc05ee7..0d366e43f4 100644
--- a/indra/newview/llinventorymodelbackgroundfetch.cpp
+++ b/indra/newview/llinventorymodelbackgroundfetch.cpp
@@ -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();
}
diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp
index 25f1854765..79917fb11b 100644
--- a/indra/newview/llinventoryobserver.cpp
+++ b/indra/newview/llinventoryobserver.cpp
@@ -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"
diff --git a/indra/newview/llinventoryobserver.h b/indra/newview/llinventoryobserver.h
index 02f73a5892..f0ed2f7003 100644
--- a/indra/newview/llinventoryobserver.h
+++ b/indra/newview/llinventoryobserver.h
@@ -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;
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index d8de269c3c..6c7e815b04 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -671,7 +671,7 @@ bool LLViewerInventoryCategory::fetch()
}
if (!url.empty() || AISAPI::isAvailable())
{
- LLInventoryModelBackgroundFetch::instance().start(mUUID, false);
+ LLInventoryModelBackgroundFetch::instance().start(mUUID, false);
}
return true;
}