SL-14182 remove old script asset file after saving changes and allow renaming files if destination file exists
parent
1c94c929ea
commit
3b4bd86a1d
|
|
@ -99,12 +99,16 @@ bool LLFileSystem::renameFile(const LLUUID& old_file_id, const LLAssetType::ETyp
|
|||
new_file_id.toString(new_id_str);
|
||||
const std::string new_filename = LLDiskCache::getInstance()->metaDataToFilepath(new_id_str, new_file_type, extra_info);
|
||||
|
||||
// Rename needs the new file to not exist.
|
||||
LLFileSystem::removeFile(new_file_id, new_file_type);
|
||||
|
||||
if (std::rename(old_filename.c_str(), new_filename.c_str()))
|
||||
{
|
||||
// We would like to return FALSE here indicating the operation
|
||||
// failed but the original code does not and doing so seems to
|
||||
// break a lot of things so we go with the flow...
|
||||
//return FALSE;
|
||||
LL_WARNS() << "Failed to rename " << old_file_id << " to " << new_id_str << " reason: " << strerror(errno) << LL_ENDL;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -1693,8 +1693,11 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/)
|
|||
{
|
||||
std::string buffer(mScriptEd->mEditor->getText());
|
||||
|
||||
LLUUID old_asset_id = inv_item->getAssetUUID().isNull() ? mScriptEd->getAssetID() : inv_item->getAssetUUID();
|
||||
|
||||
LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLScriptAssetUpload>(mItemUUID, buffer,
|
||||
[](LLUUID itemId, LLUUID, LLUUID, LLSD response) {
|
||||
[old_asset_id](LLUUID itemId, LLUUID, LLUUID, LLSD response) {
|
||||
LLFileSystem::removeFile(old_asset_id, LLAssetType::AT_LSL_TEXT);
|
||||
LLPreviewLSL::finishedLSLUpload(itemId, response);
|
||||
}));
|
||||
|
||||
|
|
@ -1742,6 +1745,7 @@ void LLPreviewLSL::onLoadComplete(const LLUUID& asset_uuid, LLAssetType::EType t
|
|||
}
|
||||
preview->mScriptEd->setScriptName(script_name);
|
||||
preview->mScriptEd->setEnableEditing(is_modifiable);
|
||||
preview->mScriptEd->setAssetID(asset_uuid);
|
||||
preview->mAssetStatus = PREVIEW_ASSET_LOADED;
|
||||
}
|
||||
else
|
||||
|
|
@ -1995,6 +1999,7 @@ void LLLiveLSLEditor::onLoadComplete(const LLUUID& asset_id,
|
|||
instance->loadScriptText(asset_id, type);
|
||||
instance->mScriptEd->setEnableEditing(TRUE);
|
||||
instance->mAssetStatus = PREVIEW_ASSET_LOADED;
|
||||
instance->mScriptEd->setAssetID(asset_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2174,6 +2179,7 @@ void LLLiveLSLEditor::finishLSLUpload(LLUUID itemId, LLUUID taskId, LLUUID newAs
|
|||
if (preview)
|
||||
{
|
||||
preview->mItem->setAssetUUID(newAssetId);
|
||||
preview->mScriptEd->setAssetID(newAssetId);
|
||||
|
||||
// Bytecode save completed
|
||||
if (response["compiled"])
|
||||
|
|
@ -2244,12 +2250,14 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/)
|
|||
if (!url.empty())
|
||||
{
|
||||
std::string buffer(mScriptEd->mEditor->getText());
|
||||
LLUUID old_asset_id = mScriptEd->getAssetID();
|
||||
|
||||
LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLScriptAssetUpload>(mObjectUUID, mItemUUID,
|
||||
monoChecked() ? LLScriptAssetUpload::MONO : LLScriptAssetUpload::LSL2,
|
||||
isRunning, mScriptEd->getAssociatedExperience(), buffer,
|
||||
[isRunning](LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response) {
|
||||
LLLiveLSLEditor::finishLSLUpload(itemId, taskId, newAssetId, response, isRunning);
|
||||
[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);
|
||||
}));
|
||||
|
||||
LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo);
|
||||
|
|
|
|||
|
|
@ -142,6 +142,9 @@ public:
|
|||
|
||||
void setItemRemoved(bool script_removed){mScriptRemoved = script_removed;};
|
||||
|
||||
void setAssetID( const LLUUID& asset_id){ mAssetID = asset_id; };
|
||||
LLUUID getAssetID() { return mAssetID; }
|
||||
|
||||
private:
|
||||
void onBtnHelp();
|
||||
void onBtnDynamicHelp();
|
||||
|
|
@ -188,6 +191,7 @@ private:
|
|||
LLUUID mAssociatedExperience;
|
||||
BOOL mScriptRemoved;
|
||||
BOOL mSaveDialogShown;
|
||||
LLUUID mAssetID;
|
||||
|
||||
LLScriptEdContainer* mContainer; // parent view
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue