diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs | 138 |
1 files changed, 24 insertions, 114 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 8a4fd8f..da1ff2e 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs | |||
@@ -57,39 +57,36 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
57 | } | 57 | } |
58 | 58 | ||
59 | /// <summary> | 59 | /// <summary> |
60 | /// Return a xfer uploader if one does not already exist. | 60 | /// Return the xfer uploader for the given transaction. |
61 | /// </summary> | 61 | /// </summary> |
62 | /// <remarks> | ||
63 | /// If an uploader does not already exist for this transaction then it is created, otherwise the existing | ||
64 | /// uploader is returned. | ||
65 | /// </remarks> | ||
62 | /// <param name="transactionID"></param> | 66 | /// <param name="transactionID"></param> |
63 | /// <param name="assetID"> | 67 | /// <returns>The asset xfer uploader</returns> |
64 | /// We must transfer the new asset ID into the uploader on creation, otherwise | 68 | public AssetXferUploader RequestXferUploader(UUID transactionID) |
65 | /// we can see race conditions with other threads which can retrieve an item before it is updated with the new | ||
66 | /// asset id. | ||
67 | /// </param> | ||
68 | /// <returns> | ||
69 | /// The xfer uploader requested. Null if one is already in existence. | ||
70 | /// FIXME: This is a bizarre thing to do, and is probably meant to signal an error condition if multiple | ||
71 | /// transfers are made. Needs to be corrected. | ||
72 | /// </returns> | ||
73 | public AssetXferUploader RequestXferUploader(UUID transactionID, UUID assetID) | ||
74 | { | 69 | { |
70 | AssetXferUploader uploader; | ||
71 | |||
75 | lock (XferUploaders) | 72 | lock (XferUploaders) |
76 | { | 73 | { |
77 | if (!XferUploaders.ContainsKey(transactionID)) | 74 | if (!XferUploaders.ContainsKey(transactionID)) |
78 | { | 75 | { |
79 | AssetXferUploader uploader = new AssetXferUploader(this, m_Scene, assetID, m_dumpAssetsToFile); | 76 | uploader = new AssetXferUploader(this, m_Scene, transactionID, m_dumpAssetsToFile); |
80 | 77 | ||
81 | // m_log.DebugFormat( | 78 | // m_log.DebugFormat( |
82 | // "[AGENT ASSETS TRANSACTIONS]: Adding asset xfer uploader {0} since it didn't previously exist", transactionID); | 79 | // "[AGENT ASSETS TRANSACTIONS]: Adding asset xfer uploader {0} since it didn't previously exist", transactionID); |
83 | 80 | ||
84 | XferUploaders.Add(transactionID, uploader); | 81 | XferUploaders.Add(transactionID, uploader); |
85 | 82 | } | |
86 | return uploader; | 83 | else |
84 | { | ||
85 | uploader = XferUploaders[transactionID]; | ||
87 | } | 86 | } |
88 | } | 87 | } |
89 | 88 | ||
90 | m_log.WarnFormat("[AGENT ASSETS TRANSACTIONS]: Ignoring request for asset xfer uploader {0} since it already exists", transactionID); | 89 | return uploader; |
91 | |||
92 | return null; | ||
93 | } | 90 | } |
94 | 91 | ||
95 | public void HandleXfer(ulong xferID, uint packetID, byte[] data) | 92 | public void HandleXfer(ulong xferID, uint packetID, byte[] data) |
@@ -151,117 +148,30 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
151 | string description, string name, sbyte invType, | 148 | string description, string name, sbyte invType, |
152 | sbyte type, byte wearableType, uint nextOwnerMask) | 149 | sbyte type, byte wearableType, uint nextOwnerMask) |
153 | { | 150 | { |
154 | AssetXferUploader uploader = null; | 151 | AssetXferUploader uploader = RequestXferUploader(transactionID); |
155 | |||
156 | lock (XferUploaders) | ||
157 | { | ||
158 | if (XferUploaders.ContainsKey(transactionID)) | ||
159 | uploader = XferUploaders[transactionID]; | ||
160 | } | ||
161 | 152 | ||
162 | if (uploader != null) | 153 | uploader.RequestCreateInventoryItem( |
163 | { | 154 | remoteClient, folderID, callbackID, |
164 | uploader.RequestCreateInventoryItem( | 155 | description, name, invType, type, wearableType, nextOwnerMask); |
165 | remoteClient, transactionID, folderID, | ||
166 | callbackID, description, name, invType, type, | ||
167 | wearableType, nextOwnerMask); | ||
168 | 156 | ||
169 | return true; | 157 | return true; |
170 | } | ||
171 | |||
172 | return false; | ||
173 | } | ||
174 | |||
175 | /// <summary> | ||
176 | /// Get an uploaded asset. If the data is successfully retrieved, | ||
177 | /// the transaction will be removed. | ||
178 | /// </summary> | ||
179 | /// <param name="transactionID"></param> | ||
180 | /// <returns>The asset if the upload has completed, null if it has not.</returns> | ||
181 | private AssetBase GetTransactionAsset(UUID transactionID) | ||
182 | { | ||
183 | lock (XferUploaders) | ||
184 | { | ||
185 | if (XferUploaders.ContainsKey(transactionID)) | ||
186 | { | ||
187 | AssetXferUploader uploader = XferUploaders[transactionID]; | ||
188 | AssetBase asset = uploader.GetAssetData(); | ||
189 | RemoveXferUploader(transactionID); | ||
190 | |||
191 | return asset; | ||
192 | } | ||
193 | } | ||
194 | |||
195 | return null; | ||
196 | } | 158 | } |
197 | 159 | ||
198 | public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, | 160 | public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, |
199 | SceneObjectPart part, UUID transactionID, | 161 | SceneObjectPart part, UUID transactionID, |
200 | TaskInventoryItem item) | 162 | TaskInventoryItem item) |
201 | { | 163 | { |
202 | AssetXferUploader uploader = null; | 164 | AssetXferUploader uploader = RequestXferUploader(transactionID); |
203 | |||
204 | lock (XferUploaders) | ||
205 | { | ||
206 | if (XferUploaders.ContainsKey(transactionID)) | ||
207 | uploader = XferUploaders[transactionID]; | ||
208 | } | ||
209 | |||
210 | if (uploader != null) | ||
211 | { | ||
212 | AssetBase asset = GetTransactionAsset(transactionID); | ||
213 | |||
214 | // Only legacy viewers use this, and they prefer CAPS, which | ||
215 | // we have, so this really never runs. | ||
216 | // Allow it, but only for "safe" types. | ||
217 | if ((InventoryType)item.InvType != InventoryType.Notecard && | ||
218 | (InventoryType)item.InvType != InventoryType.LSL) | ||
219 | return; | ||
220 | 165 | ||
221 | if (asset != null) | 166 | uploader.RequestUpdateTaskInventoryItem(remoteClient, item); |
222 | { | ||
223 | // m_log.DebugFormat( | ||
224 | // "[AGENT ASSETS TRANSACTIONS]: Updating item {0} in {1} for transaction {2}", | ||
225 | // item.Name, part.Name, transactionID); | ||
226 | |||
227 | asset.FullID = UUID.Random(); | ||
228 | asset.Name = item.Name; | ||
229 | asset.Description = item.Description; | ||
230 | asset.Type = (sbyte)item.Type; | ||
231 | item.AssetID = asset.FullID; | ||
232 | |||
233 | m_Scene.AssetService.Store(asset); | ||
234 | } | ||
235 | } | ||
236 | else | ||
237 | { | ||
238 | m_log.ErrorFormat( | ||
239 | "[AGENT ASSET TRANSACTIONS]: Could not find uploader with transaction ID {0} when handling request to update task inventory item {1} in {2}", | ||
240 | transactionID, item.Name, part.Name); | ||
241 | } | ||
242 | } | 167 | } |
243 | 168 | ||
244 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, | 169 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, |
245 | UUID transactionID, InventoryItemBase item) | 170 | UUID transactionID, InventoryItemBase item) |
246 | { | 171 | { |
247 | AssetXferUploader uploader = null; | 172 | AssetXferUploader uploader = RequestXferUploader(transactionID); |
248 | |||
249 | lock (XferUploaders) | ||
250 | { | ||
251 | if (XferUploaders.ContainsKey(transactionID)) | ||
252 | uploader = XferUploaders[transactionID]; | ||
253 | } | ||
254 | 173 | ||
255 | if (uploader != null) | 174 | uploader.RequestUpdateInventoryItem(remoteClient, item); |
256 | { | ||
257 | uploader.RequestUpdateInventoryItem(remoteClient, transactionID, item); | ||
258 | } | ||
259 | else | ||
260 | { | ||
261 | m_log.ErrorFormat( | ||
262 | "[AGENT ASSET TRANSACTIONS]: Could not find uploader with transaction ID {0} when handling request to update inventory item {1} for {2}", | ||
263 | transactionID, item.Name, remoteClient.Name); | ||
264 | } | ||
265 | } | 175 | } |
266 | } | 176 | } |
267 | } | 177 | } |