diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs | 138 |
1 files changed, 114 insertions, 24 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index da1ff2e..8a4fd8f 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs | |||
@@ -57,36 +57,39 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
57 | } | 57 | } |
58 | 58 | ||
59 | /// <summary> | 59 | /// <summary> |
60 | /// Return the xfer uploader for the given transaction. | 60 | /// Return a xfer uploader if one does not already exist. |
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> | ||
66 | /// <param name="transactionID"></param> | 62 | /// <param name="transactionID"></param> |
67 | /// <returns>The asset xfer uploader</returns> | 63 | /// <param name="assetID"> |
68 | public AssetXferUploader RequestXferUploader(UUID transactionID) | 64 | /// We must transfer the new asset ID into the uploader on creation, otherwise |
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) | ||
69 | { | 74 | { |
70 | AssetXferUploader uploader; | ||
71 | |||
72 | lock (XferUploaders) | 75 | lock (XferUploaders) |
73 | { | 76 | { |
74 | if (!XferUploaders.ContainsKey(transactionID)) | 77 | if (!XferUploaders.ContainsKey(transactionID)) |
75 | { | 78 | { |
76 | uploader = new AssetXferUploader(this, m_Scene, transactionID, m_dumpAssetsToFile); | 79 | AssetXferUploader uploader = new AssetXferUploader(this, m_Scene, assetID, m_dumpAssetsToFile); |
77 | 80 | ||
78 | // m_log.DebugFormat( | 81 | // m_log.DebugFormat( |
79 | // "[AGENT ASSETS TRANSACTIONS]: Adding asset xfer uploader {0} since it didn't previously exist", transactionID); | 82 | // "[AGENT ASSETS TRANSACTIONS]: Adding asset xfer uploader {0} since it didn't previously exist", transactionID); |
80 | 83 | ||
81 | XferUploaders.Add(transactionID, uploader); | 84 | XferUploaders.Add(transactionID, uploader); |
82 | } | 85 | |
83 | else | 86 | return uploader; |
84 | { | ||
85 | uploader = XferUploaders[transactionID]; | ||
86 | } | 87 | } |
87 | } | 88 | } |
88 | 89 | ||
89 | return uploader; | 90 | m_log.WarnFormat("[AGENT ASSETS TRANSACTIONS]: Ignoring request for asset xfer uploader {0} since it already exists", transactionID); |
91 | |||
92 | return null; | ||
90 | } | 93 | } |
91 | 94 | ||
92 | public void HandleXfer(ulong xferID, uint packetID, byte[] data) | 95 | public void HandleXfer(ulong xferID, uint packetID, byte[] data) |
@@ -148,30 +151,117 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
148 | string description, string name, sbyte invType, | 151 | string description, string name, sbyte invType, |
149 | sbyte type, byte wearableType, uint nextOwnerMask) | 152 | sbyte type, byte wearableType, uint nextOwnerMask) |
150 | { | 153 | { |
151 | AssetXferUploader uploader = RequestXferUploader(transactionID); | 154 | AssetXferUploader uploader = null; |
155 | |||
156 | lock (XferUploaders) | ||
157 | { | ||
158 | if (XferUploaders.ContainsKey(transactionID)) | ||
159 | uploader = XferUploaders[transactionID]; | ||
160 | } | ||
152 | 161 | ||
153 | uploader.RequestCreateInventoryItem( | 162 | if (uploader != null) |
154 | remoteClient, folderID, callbackID, | 163 | { |
155 | description, name, invType, type, wearableType, nextOwnerMask); | 164 | uploader.RequestCreateInventoryItem( |
165 | remoteClient, transactionID, folderID, | ||
166 | callbackID, description, name, invType, type, | ||
167 | wearableType, nextOwnerMask); | ||
156 | 168 | ||
157 | return true; | 169 | 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; | ||
158 | } | 196 | } |
159 | 197 | ||
160 | public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, | 198 | public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, |
161 | SceneObjectPart part, UUID transactionID, | 199 | SceneObjectPart part, UUID transactionID, |
162 | TaskInventoryItem item) | 200 | TaskInventoryItem item) |
163 | { | 201 | { |
164 | AssetXferUploader uploader = RequestXferUploader(transactionID); | 202 | AssetXferUploader uploader = null; |
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; | ||
165 | 220 | ||
166 | uploader.RequestUpdateTaskInventoryItem(remoteClient, item); | 221 | if (asset != null) |
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 | } | ||
167 | } | 242 | } |
168 | 243 | ||
169 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, | 244 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, |
170 | UUID transactionID, InventoryItemBase item) | 245 | UUID transactionID, InventoryItemBase item) |
171 | { | 246 | { |
172 | AssetXferUploader uploader = RequestXferUploader(transactionID); | 247 | AssetXferUploader uploader = null; |
248 | |||
249 | lock (XferUploaders) | ||
250 | { | ||
251 | if (XferUploaders.ContainsKey(transactionID)) | ||
252 | uploader = XferUploaders[transactionID]; | ||
253 | } | ||
173 | 254 | ||
174 | uploader.RequestUpdateInventoryItem(remoteClient, item); | 255 | if (uploader != null) |
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 | } | ||
175 | } | 265 | } |
176 | } | 266 | } |
177 | } | 267 | } |