aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-09-25 22:08:11 +0100
committerMelanie2012-09-27 15:26:58 +0100
commit65e294267df7fb3892d3d926182794f51ce42a71 (patch)
treef3a08f427dcfd6f1213be54b078850d374f71786 /OpenSim/Region
parentFix occasional race condition failure when creating new clothing/body parts i... (diff)
downloadopensim-SC-65e294267df7fb3892d3d926182794f51ce42a71.zip
opensim-SC-65e294267df7fb3892d3d926182794f51ce42a71.tar.gz
opensim-SC-65e294267df7fb3892d3d926182794f51ce42a71.tar.bz2
opensim-SC-65e294267df7fb3892d3d926182794f51ce42a71.tar.xz
Move UDP update task item code to AssetXferUploader to match existing create user item and update user item mechanisms
This is done for consistency and to allow removal or some access methods that increase code complexity. However, this path has not been used for a long time, not even by LL 1.23 - viewers use caps http upload for this instead
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs47
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs53
3 files changed, 52 insertions, 50 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
index bba7b9c..59d0075 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
@@ -155,56 +155,13 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
155 description, name, invType, type, wearableType, nextOwnerMask); 155 description, name, invType, type, wearableType, nextOwnerMask);
156 } 156 }
157 157
158 /// <summary>
159 /// Get an uploaded asset. If the data is successfully retrieved,
160 /// the transaction will be removed.
161 /// </summary>
162 /// <param name="transactionID"></param>
163 /// <returns>The asset if the upload has completed, null if it has not.</returns>
164 private AssetBase GetTransactionAsset(UUID transactionID)
165 {
166 lock (XferUploaders)
167 {
168 if (XferUploaders.ContainsKey(transactionID))
169 {
170 AssetXferUploader uploader = XferUploaders[transactionID];
171 AssetBase asset = uploader.GetAssetData();
172 RemoveXferUploader(transactionID);
173
174 return asset;
175 }
176 }
177
178 return null;
179 }
180
181 public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, 158 public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient,
182 SceneObjectPart part, UUID transactionID, 159 SceneObjectPart part, UUID transactionID,
183 TaskInventoryItem item) 160 TaskInventoryItem item)
184 { 161 {
185 AssetBase asset = GetTransactionAsset(transactionID); 162 AssetXferUploader uploader = RequestXferUploader(transactionID);
186
187 // Only legacy viewers use this, and they prefer CAPS, which
188 // we have, so this really never runs.
189 // Allow it, but only for "safe" types.
190 if ((InventoryType)item.InvType != InventoryType.Notecard &&
191 (InventoryType)item.InvType != InventoryType.LSL)
192 return;
193 163
194 if (asset != null) 164 uploader.RequestUpdateTaskInventoryItem(remoteClient, transactionID, item);
195 {
196// m_log.DebugFormat(
197// "[AGENT ASSETS TRANSACTIONS]: Updating item {0} in {1} for transaction {2}",
198// item.Name, part.Name, transactionID);
199
200 asset.FullID = UUID.Random();
201 asset.Name = item.Name;
202 asset.Description = item.Description;
203 asset.Type = (sbyte)item.Type;
204 item.AssetID = asset.FullID;
205
206 m_Scene.AssetService.Store(asset);
207 }
208 } 165 }
209 166
210 public void RequestUpdateInventoryItem(IClientAPI remoteClient, 167 public void RequestUpdateInventoryItem(IClientAPI remoteClient,
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
index 10a0794..73d1f72 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
@@ -215,7 +215,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
215 IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) 215 IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item)
216 { 216 {
217 m_log.DebugFormat( 217 m_log.DebugFormat(
218 "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0} in {1} for {2} in {3}", 218 "[ASSET TRANSACTION MODULE] Called HandleTaskItemUpdateFromTransaction with item {0} in {1} for {2} in {3}",
219 item.Name, part.Name, remoteClient.Name, m_Scene.RegionInfo.RegionName); 219 item.Name, part.Name, remoteClient.Name, m_Scene.RegionInfo.RegionName);
220 220
221 AgentAssetTransactions transactions = 221 AgentAssetTransactions transactions =
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
index d134c43..96f0d0f 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
@@ -73,11 +73,15 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
73 private UUID InventFolder = UUID.Zero; 73 private UUID InventFolder = UUID.Zero;
74 private sbyte invType = 0; 74 private sbyte invType = 0;
75 75
76 private bool m_createItem = false; 76 private bool m_createItem;
77 private uint m_createItemCallback = 0; 77 private uint m_createItemCallback;
78 private bool m_updateItem = false; 78
79 private bool m_updateItem;
79 private InventoryItemBase m_updateItemData; 80 private InventoryItemBase m_updateItemData;
80 81
82 private bool m_updateTaskItem;
83 private TaskInventoryItem m_updateTaskItemData;
84
81 private string m_description = String.Empty; 85 private string m_description = String.Empty;
82 private bool m_dumpAssetToFile; 86 private bool m_dumpAssetToFile;
83 private string m_name = String.Empty; 87 private string m_name = String.Empty;
@@ -232,6 +236,12 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
232 // TODO: Should probably do the same for create item. 236 // TODO: Should probably do the same for create item.
233 m_transactions.RemoveXferUploader(TransactionID); 237 m_transactions.RemoveXferUploader(TransactionID);
234 } 238 }
239 else if (m_updateTaskItem)
240 {
241 StoreAssetForTaskItemUpdate(m_updateTaskItemData);
242
243 m_transactions.RemoveXferUploader(TransactionID);
244 }
235 else if (m_storeLocal) 245 else if (m_storeLocal)
236 { 246 {
237 m_Scene.AssetService.Store(m_asset); 247 m_Scene.AssetService.Store(m_asset);
@@ -332,8 +342,30 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
332 } 342 }
333 } 343 }
334 344
345 public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, UUID transactionID, TaskInventoryItem taskItem)
346 {
347 // We must lock to avoid a race with a separate thread uploading the asset.
348 lock (this)
349 {
350 m_asset.Name = taskItem.Name;
351 m_asset.Description = taskItem.Description;
352 m_asset.Type = (sbyte)taskItem.Type;
353 taskItem.AssetID = m_asset.FullID;
354
355 if (m_uploadState == UploadState.Complete)
356 {
357 StoreAssetForTaskItemUpdate(taskItem);
358 }
359 else
360 {
361 m_updateTaskItem = true;
362 m_updateTaskItemData = taskItem;
363 }
364 }
365 }
366
335 /// <summary> 367 /// <summary>
336 /// Store the asset for the given item. 368 /// Store the asset for the given item when it has been uploaded.
337 /// </summary> 369 /// </summary>
338 /// <param name="item"></param> 370 /// <param name="item"></param>
339 private void StoreAssetForItemUpdate(InventoryItemBase item) 371 private void StoreAssetForItemUpdate(InventoryItemBase item)
@@ -345,6 +377,19 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
345 m_Scene.AssetService.Store(m_asset); 377 m_Scene.AssetService.Store(m_asset);
346 } 378 }
347 379
380 /// <summary>
381 /// Store the asset for the given task item when it has been uploaded.
382 /// </summary>
383 /// <param name="taskItem"></param>
384 private void StoreAssetForTaskItemUpdate(TaskInventoryItem taskItem)
385 {
386// m_log.DebugFormat(
387// "[ASSET XFER UPLOADER]: Storing asset {0} for earlier task item update for {1} for {2}",
388// m_asset.FullID, taskItem.Name, ourClient.Name);
389
390 m_Scene.AssetService.Store(m_asset);
391 }
392
348 private void DoCreateItem(uint callbackID) 393 private void DoCreateItem(uint callbackID)
349 { 394 {
350 ValidateAssets(); 395 ValidateAssets();