SL-18777 PBR upload was stuck waiting for texture

Handle obscure upload failure case - floater was waiting for a texture upload indefinetely.
Unblock floater if upload fails.
meow-7.2.2
akleshchev 2022-12-07 02:16:12 +02:00 committed by GitHub
parent c033278ec2
commit c69c8aa347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 251 additions and 92 deletions

View File

@ -124,7 +124,7 @@ public:
LLQueuedScriptAssetUpload(LLUUID taskId, LLUUID itemId, LLUUID assetId, TargetType_t targetType,
bool isRunning, std::string scriptName, LLUUID queueId, LLUUID exerienceId, taskUploadFinish_f finish) :
LLScriptAssetUpload(taskId, itemId, targetType, isRunning,
exerienceId, std::string(), finish),
exerienceId, std::string(), finish, nullptr),
mScriptName(scriptName),
mQueueId(queueId)
{

View File

@ -347,6 +347,7 @@ LLMaterialEditor::LLMaterialEditor(const LLSD& key)
, mRevertedChanges(0)
, mExpectedUploadCost(0)
, mUploadingTexturesCount(0)
, mUploadingTexturesFailure(false)
{
const LLInventoryItem* item = getItem();
if (item)
@ -1251,9 +1252,9 @@ bool LLMaterialEditor::saveIfNeeded()
{
if (mUploadingTexturesCount > 0)
{
// upload already in progress
// wait until textures upload
// will retry saving on callback
// Upload already in progress, wait until
// textures upload will retry saving on callback.
// Also should prevent some failure-callbacks
return true;
}
@ -1318,18 +1319,38 @@ bool LLMaterialEditor::updateInventoryItem(const std::string &buffer, const LLUU
if (task_id.isNull() && !agent_url.empty())
{
uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>(item_id, LLAssetType::AT_MATERIAL, buffer,
[](LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD) {
LLMaterialEditor::finishInventoryUpload(itemId, newAssetId, newItemId);
});
[](LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD)
{
// done callback
LLMaterialEditor::finishInventoryUpload(itemId, newAssetId, newItemId);
},
nullptr // failure callback
);
url = agent_url;
}
else if (!task_id.isNull() && !task_url.empty())
{
LLUUID object_uuid(task_id);
uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>(task_id, item_id, LLAssetType::AT_MATERIAL, buffer,
[object_uuid](LLUUID itemId, LLUUID, LLUUID newAssetId, LLSD) {
LLMaterialEditor::finishTaskUpload(itemId, newAssetId, object_uuid);
});
[](LLUUID itemId, LLUUID task_id, LLUUID newAssetId, LLSD)
{
// done callback
LLMaterialEditor::finishTaskUpload(itemId, newAssetId, task_id);
},
[](LLUUID itemId, LLUUID task_id, LLSD response, std::string reason)
{
// failure callback
LLSD floater_key;
floater_key["taskid"] = task_id;
floater_key["itemid"] = itemId;
LLMaterialEditor* me = LLFloaterReg::findTypedInstance<LLMaterialEditor>("material_editor", floater_key);
if (me)
{
me->setEnabled(true);
}
return true;
}
);
url = task_url;
}
@ -1394,11 +1415,15 @@ void LLMaterialEditor::createInventoryItem(const std::string &buffer, const std:
inv_item_id,
LLAssetType::AT_MATERIAL,
output,
[](LLUUID item_id, LLUUID new_asset_id, LLUUID new_item_id, LLSD response) {
LL_INFOS("Material") << "inventory item uploaded. item: " << item_id << " asset: " << new_asset_id << " new_item_id: " << new_item_id << " response: " << response << LL_ENDL;
LLSD params = llsd::map("ASSET_ID", new_asset_id);
LLNotificationsUtil::add("MaterialCreated", params);
});
[](LLUUID item_id, LLUUID new_asset_id, LLUUID new_item_id, LLSD response)
{
// done callback
LL_INFOS("Material") << "inventory item uploaded. item: " << item_id << " asset: " << new_asset_id << " new_item_id: " << new_item_id << " response: " << response << LL_ENDL;
LLSD params = llsd::map("ASSET_ID", new_asset_id);
LLNotificationsUtil::add("MaterialCreated", params);
},
nullptr // failure callback, floater already closed
);
const LLViewerRegion* region = gAgent.getRegion();
if (region)
@ -1729,6 +1754,8 @@ void LLMaterialEditor::uploadMaterialFromFile(const std::string& filename, S32 i
}
// Todo: no point in loading whole editor
// This uses 'filename' to make sure multiple bulk uploads work
// instead of fighting for a single instance.
LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor", LLSD().with("filename", filename).with("index", LLSD::Integer(index)));
me->loadMaterial(model_in, filename_lc, index, false);
me->saveIfNeeded();
@ -2012,21 +2039,6 @@ void LLMaterialEditor::onSaveObjectsMaterialAsMsgCallback(const LLSD& notificati
}
}
void LLMaterialEditor::loadFromGLTFMaterial(LLUUID &asset_id)
{
if (asset_id.isNull())
{
LL_WARNS("MaterialEditor") << "Trying to open material with null id" << LL_ENDL;
return;
}
LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor");
me->mMaterialName = LLTrans::getString("New Material");
me->setTitle(me->mMaterialName);
me->setFromGLTFMaterial(gGLTFMaterialList.getMaterial(asset_id));
me->openFloater();
me->setFocus(TRUE);
}
void LLMaterialEditor::loadMaterial(const tinygltf::Model &model_in, const std::string &filename_lc, S32 index, bool open_floater)
{
if (model_in.materials.size() <= index)
@ -3008,6 +3020,16 @@ void LLMaterialEditor::saveTexture(LLImageJ2C* img, const std::string& name, con
U32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost();
LLSD key = getKey();
std::function<bool(LLUUID itemId, LLSD response, std::string reason)> failed_upload([key](LLUUID assetId, LLSD response, std::string reason)
{
LLMaterialEditor* me = LLFloaterReg::findTypedInstance<LLMaterialEditor>("material_editor", key);
if (me)
{
me->setFailedToUploadTexture();
}
return true; // handled
});
LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLNewBufferedResourceUploadInfo>(
buffer,
@ -3023,13 +3045,26 @@ void LLMaterialEditor::saveTexture(LLImageJ2C* img, const std::string& name, con
LLFloaterPerms::getEveryonePerms("Uploads"),
expected_upload_cost,
false,
cb));
cb,
failed_upload));
upload_new_resource(uploadInfo);
}
void LLMaterialEditor::setFailedToUploadTexture()
{
mUploadingTexturesFailure = true;
mUploadingTexturesCount--;
if (mUploadingTexturesCount == 0)
{
setEnabled(true);
}
}
S32 LLMaterialEditor::saveTextures()
{
mUploadingTexturesFailure = false; // not supposed to get here if already uploading
S32 work_count = 0;
LLSD key = getKey(); // must be locally declared for lambda's capture to work
if (mBaseColorTextureUploadId == getBaseColorId() && mBaseColorTextureUploadId.notNull())
@ -3044,16 +3079,29 @@ S32 LLMaterialEditor::saveTextures()
if (response["success"].asBoolean())
{
me->setBaseColorId(newAssetId);
// discard upload buffers once texture have been saved
me->mBaseColorJ2C = nullptr;
me->mBaseColorFetched = nullptr;
me->mBaseColorTextureUploadId.setNull();
me->mUploadingTexturesCount--;
if (!me->mUploadingTexturesFailure)
{
// try saving
me->saveIfNeeded();
}
else if (me->mUploadingTexturesCount == 0)
{
me->setEnabled(true);
}
}
else
{
// To make sure that we won't retry (some failures can cb immediately)
me->setBaseColorId(LLUUID::null);
// stop upload if possible, unblock and let user decide
me->setFailedToUploadTexture();
}
me->mUploadingTexturesCount--;
// try saving
me->saveIfNeeded();
}
});
}
@ -3069,16 +3117,29 @@ S32 LLMaterialEditor::saveTextures()
if (response["success"].asBoolean())
{
me->setNormalId(newAssetId);
// discard upload buffers once texture have been saved
me->mNormalJ2C = nullptr;
me->mNormalFetched = nullptr;
me->mNormalTextureUploadId.setNull();
me->mUploadingTexturesCount--;
if (!me->mUploadingTexturesFailure)
{
// try saving
me->saveIfNeeded();
}
else if (me->mUploadingTexturesCount == 0)
{
me->setEnabled(true);
}
}
else
{
me->setNormalId(LLUUID::null);
// stop upload if possible, unblock and let user decide
me->setFailedToUploadTexture();
}
me->setNormalId(newAssetId);
me->mUploadingTexturesCount--;
// try saving
me->saveIfNeeded();
}
});
}
@ -3094,15 +3155,29 @@ S32 LLMaterialEditor::saveTextures()
if (response["success"].asBoolean())
{
me->setMetallicRoughnessId(newAssetId);
// discard upload buffers once texture have been saved
me->mMetallicRoughnessJ2C = nullptr;
me->mMetallicRoughnessFetched = nullptr;
me->mMetallicTextureUploadId.setNull();
me->mUploadingTexturesCount--;
if (!me->mUploadingTexturesFailure)
{
// try saving
me->saveIfNeeded();
}
else if (me->mUploadingTexturesCount == 0)
{
me->setEnabled(true);
}
}
else
{
me->setMetallicRoughnessId(LLUUID::null);
// stop upload if possible, unblock and let user decide
me->setFailedToUploadTexture();
}
me->mUploadingTexturesCount--;
// try saving
me->saveIfNeeded();
}
});
}
@ -3119,21 +3194,39 @@ S32 LLMaterialEditor::saveTextures()
if (response["success"].asBoolean())
{
me->setEmissiveId(newAssetId);
// discard upload buffers once texture have been saved
me->mEmissiveJ2C = nullptr;
me->mEmissiveFetched = nullptr;
me->mEmissiveTextureUploadId.setNull();
me->mUploadingTexturesCount--;
if (!me->mUploadingTexturesFailure)
{
// try saving
me->saveIfNeeded();
}
else if (me->mUploadingTexturesCount == 0)
{
me->setEnabled(true);
}
}
else
{
me->setEmissiveId(LLUUID::null);
// stop upload if possible, unblock and let user decide
me->setFailedToUploadTexture();
}
me->mUploadingTexturesCount--;
// try saving
me->saveIfNeeded();
}
});
}
// discard upload buffers once textures have been saved
clearTextures();
if (!work_count)
{
// Discard upload buffers once textures have been confirmed as saved.
// Otherwise we keep buffers for potential upload failure recovery.
clearTextures();
}
// asset storage can callback immediately, causing a decrease
// of mUploadingTexturesCount, report amount of work scheduled

View File

@ -116,14 +116,13 @@ public:
static void savePickedMaterialAs();
static void onSaveObjectsMaterialAsMsgCallback(const LLSD& notification, const LLSD& response);
static void loadFromGLTFMaterial(LLUUID &asset_id);
static void onLoadComplete(const LLUUID& asset_uuid, LLAssetType::EType type, void* user_data, S32 status, LLExtStat ext_status);
void inventoryChanged(LLViewerObject* object, LLInventoryObject::object_list_t* inventory, S32 serial_num, void* user_data) override;
typedef std::function<void(LLUUID newAssetId, LLSD response)> upload_callback_f;
void saveTexture(LLImageJ2C* img, const std::string& name, const LLUUID& asset_id, upload_callback_f cb);
void setFailedToUploadTexture();
// save textures to inventory if needed
// returns amount of scheduled uploads
@ -295,6 +294,7 @@ private:
U32 mRevertedChanges; // flags to indicate individual reverted parameters
S32 mUploadingTexturesCount;
S32 mExpectedUploadCost;
bool mUploadingTexturesFailure;
std::string mMaterialNameShort;
std::string mMaterialName;

View File

@ -1108,14 +1108,16 @@ void LLPreviewGesture::saveIfNeeded()
item->setComplete(true);
uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>(mItemUUID, LLAssetType::AT_GESTURE, buffer,
[](LLUUID itemId, LLUUID newAssetId, LLUUID, LLSD) {
[](LLUUID itemId, LLUUID newAssetId, LLUUID, LLSD)
{
LLPreviewGesture::finishInventoryUpload(itemId, newAssetId);
});
},
nullptr);
url = agent_url;
}
else if (!mObjectUUID.isNull() && !task_url.empty())
{
uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>(mObjectUUID, mItemUUID, LLAssetType::AT_GESTURE, buffer, nullptr);
uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>(mObjectUUID, mItemUUID, LLAssetType::AT_GESTURE, buffer, nullptr, nullptr);
url = task_url;
}

View File

@ -552,7 +552,8 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem, bool sync)
uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>(mItemUUID, LLAssetType::AT_NOTECARD, buffer,
[](LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD) {
LLPreviewNotecard::finishInventoryUpload(itemId, newAssetId, newItemId);
});
},
nullptr);
url = agent_url;
}
else if (!mObjectUUID.isNull() && !task_url.empty())
@ -561,7 +562,8 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem, bool sync)
uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>(mObjectUUID, mItemUUID, LLAssetType::AT_NOTECARD, buffer,
[object_uuid](LLUUID itemId, LLUUID, LLUUID newAssetId, LLSD) {
LLPreviewNotecard::finishTaskUpload(itemId, newAssetId, object_uuid);
});
},
nullptr);
url = task_url;
}

View File

@ -1686,6 +1686,32 @@ void LLPreviewLSL::finishedLSLUpload(LLUUID itemId, LLSD response)
}
}
bool LLPreviewLSL::failedLSLUpload(LLUUID itemId, LLUUID taskId, LLSD response, std::string reason)
{
LLSD floater_key;
if (taskId.notNull())
{
floater_key["taskid"] = taskId;
floater_key["itemid"] = itemId;
}
else
{
floater_key = LLSD(itemId);
}
LLPreviewLSL* preview = LLFloaterReg::findTypedInstance<LLPreviewLSL>("preview_script", floater_key);
if (preview)
{
// unfreeze floater
LLSD errors;
errors.append(LLTrans::getString("UploadFailed") + reason);
preview->callbackLSLCompileFailed(errors);
return true;
}
return false;
}
// Save needs to compile the text in the buffer. If the compile
// succeeds, then save both assets out to the database. If the compile
// fails, go ahead and save the text anyway.
@ -1723,7 +1749,8 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/)
[old_asset_id](LLUUID itemId, LLUUID, LLUUID, LLSD response) {
LLFileSystem::removeFile(old_asset_id, LLAssetType::AT_LSL_TEXT);
LLPreviewLSL::finishedLSLUpload(itemId, response);
}));
},
LLPreviewLSL::failedLSLUpload));
LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo);
}
@ -2282,7 +2309,8 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/)
[isRunning, old_asset_id](LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response) {
LLFileSystem::removeFile(old_asset_id, LLAssetType::AT_LSL_TEXT);
LLLiveLSLEditor::finishLSLUpload(itemId, taskId, newAssetId, response, isRunning);
}));
},
nullptr)); // needs failure handling?
LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo);
}

View File

@ -245,6 +245,7 @@ protected:
static void* createScriptEdPanel(void* userdata);
static void finishedLSLUpload(LLUUID itemId, LLSD response);
static bool failedLSLUpload(LLUUID itemId, LLUUID taskId, LLSD response, std::string reason);
protected:
// Can safely close only after both text and bytecode are uploaded

View File

@ -234,9 +234,11 @@ void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings
LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION);
LLResourceUploadInfo::ptr_t uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>(inv_item_id, LLAssetType::AT_SETTINGS, buffer.str(),
[settings, callback](LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response) {
[settings, callback](LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response)
{
LLSettingsVOBase::onAgentAssetUploadComplete(itemId, newAssetId, newItemId, response, settings, callback);
});
},
nullptr);
LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo);
}
@ -265,9 +267,11 @@ void LLSettingsVOBase::updateInventoryItem(const LLSettingsBase::ptr_t &settings
LLSDSerialize::serialize(settingdata, buffer, LLSDSerialize::LLSD_NOTATION);
LLResourceUploadInfo::ptr_t uploadInfo = std::make_shared<LLBufferedAssetUploadInfo>(object_id, inv_item_id, LLAssetType::AT_SETTINGS, buffer.str(),
[settings, callback](LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response) {
LLSettingsVOBase::onTaskAssetUploadComplete(itemId, taskId, newAssetId, response, settings, callback);
});
[settings, callback](LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response)
{
LLSettingsVOBase::onTaskAssetUploadComplete(itemId, taskId, newAssetId, response, settings, callback);
},
nullptr);
LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo);
}

View File

@ -34,7 +34,6 @@
#include "lluuid.h"
#include "llvorbisencode.h"
#include "lluploaddialog.h"
#include "llpreviewscript.h"
#include "llnotificationsutil.h"
#include "llagent.h"
#include "llfloaterreg.h"
@ -568,12 +567,14 @@ LLNewBufferedResourceUploadInfo::LLNewBufferedResourceUploadInfo(
U32 everyonePerms,
S32 expectedCost,
bool show_inventory,
uploadFinish_f finish)
uploadFinish_f finish,
uploadFailure_f failure)
: LLResourceUploadInfo(name, description, compressionInfo,
destinationType, inventoryType,
nextOWnerPerms, groupPerms, everyonePerms, expectedCost, show_inventory)
, mBuffer(buffer)
, mFinishFn(finish)
, mFailureFn(failure)
{
setAssetType(assetType);
setAssetId(asset_id);
@ -614,8 +615,18 @@ LLUUID LLNewBufferedResourceUploadInfo::finishUpload(LLSD &result)
return newItemId;
}
bool LLNewBufferedResourceUploadInfo::failedUpload(LLSD &result, std::string &reason)
{
if (mFailureFn)
{
return mFailureFn(getAssetId(), result, reason);
}
return false; // Not handled
}
//=========================================================================
LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType::EType assetType, std::string buffer, invnUploadFinish_f finish) :
LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType::EType assetType, std::string buffer, invnUploadFinish_f finish, uploadFailed_f failed) :
LLResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
0, 0, 0, 0),
mTaskUpload(false),
@ -623,6 +634,7 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType:
mContents(buffer),
mInvnFinishFn(finish),
mTaskFinishFn(nullptr),
mFailureFn(failed),
mStoredToCache(false)
{
setItemId(itemId);
@ -637,6 +649,7 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLPointer<LL
mContents(),
mInvnFinishFn(finish),
mTaskFinishFn(nullptr),
mFailureFn(nullptr),
mStoredToCache(false)
{
setItemId(itemId);
@ -663,7 +676,7 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLPointer<LL
mContents.assign((char *)image->getData(), imageSize);
}
LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish) :
LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish, uploadFailed_f failed) :
LLResourceUploadInfo(std::string(), std::string(), 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
0, 0, 0, 0),
mTaskUpload(true),
@ -671,6 +684,7 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemI
mContents(buffer),
mInvnFinishFn(nullptr),
mTaskFinishFn(finish),
mFailureFn(failed),
mStoredToCache(false)
{
setItemId(itemId);
@ -760,10 +774,19 @@ LLUUID LLBufferedAssetUploadInfo::finishUpload(LLSD &result)
return newAssetId;
}
bool LLBufferedAssetUploadInfo::failedUpload(LLSD &result, std::string &reason)
{
if (mFailureFn)
{
return mFailureFn(getItemId(), getTaskId(), result, reason);
}
return false;
}
//=========================================================================
LLScriptAssetUpload::LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish):
LLBufferedAssetUploadInfo(itemId, LLAssetType::AT_LSL_TEXT, buffer, finish),
LLScriptAssetUpload::LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish, uploadFailed_f failed):
LLBufferedAssetUploadInfo(itemId, LLAssetType::AT_LSL_TEXT, buffer, finish, failed),
mExerienceId(),
mTargetType(LSL2),
mIsRunning(false)
@ -771,8 +794,8 @@ LLScriptAssetUpload::LLScriptAssetUpload(LLUUID itemId, std::string buffer, invn
}
LLScriptAssetUpload::LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, TargetType_t targetType,
bool isRunning, LLUUID exerienceId, std::string buffer, taskUploadFinish_f finish):
LLBufferedAssetUploadInfo(taskId, itemId, LLAssetType::AT_LSL_TEXT, buffer, finish),
bool isRunning, LLUUID exerienceId, std::string buffer, taskUploadFinish_f finish, uploadFailed_f failed):
LLBufferedAssetUploadInfo(taskId, itemId, LLAssetType::AT_LSL_TEXT, buffer, finish, failed),
mExerienceId(exerienceId),
mTargetType(targetType),
mIsRunning(isRunning)
@ -986,19 +1009,15 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res
LLNotificationsUtil::add(label, args);
// unfreeze script preview
if (uploadInfo->getAssetType() == LLAssetType::AT_LSL_TEXT)
if (uploadInfo->failedUpload(result, reason))
{
LLPreviewLSL* preview = LLFloaterReg::findTypedInstance<LLPreviewLSL>("preview_script",
uploadInfo->getItemId());
if (preview)
{
LLSD errors;
errors.append(LLTrans::getString("UploadFailed") + reason);
preview->callbackLSLCompileFailed(errors);
}
// no further action required, already handled by a callback
// ex: do not trigger snapshot floater when failing material texture
return;
}
// Todo: move these floater specific actions into proper callbacks
// Let the Snapshot floater know we have failed uploading.
LLFloaterSnapshot* floater_snapshot = LLFloaterSnapshot::findInstance();
if (floater_snapshot && floater_snapshot->isWaitingState())

View File

@ -64,6 +64,9 @@ public:
virtual void logPreparedUpload();
virtual LLUUID finishUpload(LLSD &result);
// return true if no further action is need
virtual bool failedUpload(LLSD &result, std::string &reason) { return false; }
LLTransactionID getTransactionId() const { return mTransactionId; }
LLAssetType::EType getAssetType() const { return mAssetType; }
std::string getAssetTypeString() const;
@ -173,6 +176,7 @@ class LLNewBufferedResourceUploadInfo : public LLResourceUploadInfo
{
public:
typedef std::function<void(LLUUID newAssetId, LLSD response)> uploadFinish_f;
typedef std::function<bool(LLUUID assetId, LLSD response, std::string reason)> uploadFailure_f;
LLNewBufferedResourceUploadInfo(
const std::string& buffer,
@ -188,7 +192,8 @@ public:
U32 everyonePerms,
S32 expectedCost,
bool show_inventory,
uploadFinish_f finish);
uploadFinish_f finish,
uploadFailure_f failure);
virtual LLSD prepareUpload();
@ -196,9 +201,11 @@ protected:
virtual LLSD exportTempFile();
virtual LLUUID finishUpload(LLSD &result);
virtual bool failedUpload(LLSD &result, std::string &reason);
private:
uploadFinish_f mFinishFn;
uploadFailure_f mFailureFn;
std::string mBuffer;
};
@ -208,14 +215,16 @@ class LLBufferedAssetUploadInfo : public LLResourceUploadInfo
public:
typedef std::function<void(LLUUID itemId, LLUUID newAssetId, LLUUID newItemId, LLSD response)> invnUploadFinish_f;
typedef std::function<void(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response)> taskUploadFinish_f;
typedef std::function<bool(LLUUID itemId, LLUUID taskId, LLSD response, std::string reason)> uploadFailed_f;
LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType::EType assetType, std::string buffer, invnUploadFinish_f finish);
LLBufferedAssetUploadInfo(LLUUID itemId, LLAssetType::EType assetType, std::string buffer, invnUploadFinish_f finish, uploadFailed_f failed);
LLBufferedAssetUploadInfo(LLUUID itemId, LLPointer<LLImageFormatted> image, invnUploadFinish_f finish);
LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish);
LLBufferedAssetUploadInfo(LLUUID taskId, LLUUID itemId, LLAssetType::EType assetType, std::string buffer, taskUploadFinish_f finish, uploadFailed_f failed);
virtual LLSD prepareUpload();
virtual LLSD generatePostBody();
virtual LLUUID finishUpload(LLSD &result);
virtual bool failedUpload(LLSD &result, std::string &reason);
LLUUID getTaskId() const { return mTaskId; }
const std::string & getContents() const { return mContents; }
@ -232,6 +241,7 @@ private:
std::string mContents;
invnUploadFinish_f mInvnFinishFn;
taskUploadFinish_f mTaskFinishFn;
uploadFailed_f mFailureFn;
bool mStoredToCache;
};
@ -245,9 +255,9 @@ public:
MONO
};
LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish);
LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish, uploadFailed_f failed);
LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, TargetType_t targetType,
bool isRunning, LLUUID exerienceId, std::string buffer, taskUploadFinish_f finish);
bool isRunning, LLUUID exerienceId, std::string buffer, taskUploadFinish_f finish, uploadFailed_f failed);
virtual LLSD generatePostBody();