From 637e096d5718d0a174b5383aa29e3480edd734ea Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 13 Apr 2015 15:29:56 -0700 Subject: DD-388 : More resilient way of reacting to not evaluated stock count throughout marketplace handling --- indra/newview/llmarketplacefunctions.cpp | 36 ++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index de3bd35de0..88a05c1e7f 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1426,6 +1426,14 @@ bool LLMarketplaceData::createListing(const LLUUID& folder_id) { count = compute_stock_count(version_id, true); } + + // Validate the count on hand + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated, we will consider it empty (out of stock) at creation time + // It will get reevaluated and updated once the items are fetched + count = 0; + } // Post the listing creation request to SLM createSLMListing(folder_id, version_id, count); @@ -1517,7 +1525,13 @@ bool LLMarketplaceData::activateListing(const LLUUID& folder_id, bool activate) // Also update the count on hand S32 count = compute_stock_count(folder_id); - + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated locally, we should not change that SLM value + // We are assuming that this issue is local and should not modify server side values + count = getCountOnHand(listing_uuid); + } + // Post the listing update request to SLM updateSLMListing(listing_uuid, listing_id, version_uuid, activate, count); @@ -1547,6 +1561,12 @@ bool LLMarketplaceData::setVersionFolder(const LLUUID& folder_id, const LLUUID& // Also update the count on hand S32 count = compute_stock_count(version_id); + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated, we will consider it empty (out of stock) when resetting the version folder + // It will get reevaluated and updated once the items are fetched + count = 0; + } // Post the listing update request to SLM updateSLMListing(listing_uuid, listing_id, version_id, is_listed, count); @@ -1569,11 +1589,16 @@ bool LLMarketplaceData::updateCountOnHand(const LLUUID& folder_id) // Compute the new count on hand S32 count = compute_stock_count(folder_id); - if (getCountOnHand(listing_uuid) == count) + if (count == getCountOnHand(listing_uuid)) { // If count on hand is unchanged, no point spamming SLM with an update return true; } + else if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If local count on hand is not known at that point, do *not* force an update to SLM + return false; + } // Get the unchanged values bool is_listed = getActivationState(listing_uuid); @@ -1611,6 +1636,13 @@ bool LLMarketplaceData::associateListing(const LLUUID& folder_id, const LLUUID& { count = compute_stock_count(version_id, true); // Use the stock count of the new listing } + // Validate the count on hand + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated, we will consider it empty (out of stock) at reassign time + // It will get reevaluated and updated once the items are fetched + count = 0; + } // Post the listing update request to SLM updateSLMListing(folder_id, listing_id, version_id, is_listed, count); -- cgit v1.2.3