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 b557ffe..0271738 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,115 +148,28 @@ 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 | uploader.RequestCreateInventoryItem( | 154 | remoteClient, folderID, callbackID, |
164 | remoteClient, transactionID, folderID, | 155 | description, name, invType, type, wearableType, nextOwnerMask); |
165 | callbackID, description, name, invType, type, | ||
166 | wearableType, nextOwnerMask); | ||
167 | else | ||
168 | m_log.ErrorFormat( | ||
169 | "[AGENT ASSET TRANSACTIONS]: Could not find uploader with transaction ID {0} when handling request to create inventory item {1} from {2}", | ||
170 | transactionID, name, remoteClient.Name); | ||
171 | } | ||
172 | |||
173 | /// <summary> | ||
174 | /// Get an uploaded asset. If the data is successfully retrieved, | ||
175 | /// the transaction will be removed. | ||
176 | /// </summary> | ||
177 | /// <param name="transactionID"></param> | ||
178 | /// <returns>The asset if the upload has completed, null if it has not.</returns> | ||
179 | private AssetBase GetTransactionAsset(UUID transactionID) | ||
180 | { | ||
181 | lock (XferUploaders) | ||
182 | { | ||
183 | if (XferUploaders.ContainsKey(transactionID)) | ||
184 | { | ||
185 | AssetXferUploader uploader = XferUploaders[transactionID]; | ||
186 | AssetBase asset = uploader.GetAssetData(); | ||
187 | RemoveXferUploader(transactionID); | ||
188 | |||
189 | return asset; | ||
190 | } | ||
191 | } | ||
192 | |||
193 | return null; | ||
194 | } | 156 | } |
195 | 157 | ||
196 | public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, | 158 | public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, |
197 | SceneObjectPart part, UUID transactionID, | 159 | SceneObjectPart part, UUID transactionID, |
198 | TaskInventoryItem item) | 160 | TaskInventoryItem item) |
199 | { | 161 | { |
200 | AssetXferUploader uploader = null; | 162 | AssetXferUploader uploader = RequestXferUploader(transactionID); |
201 | |||
202 | lock (XferUploaders) | ||
203 | { | ||
204 | if (XferUploaders.ContainsKey(transactionID)) | ||
205 | uploader = XferUploaders[transactionID]; | ||
206 | } | ||
207 | |||
208 | if (uploader != null) | ||
209 | { | ||
210 | AssetBase asset = GetTransactionAsset(transactionID); | ||
211 | |||
212 | // Only legacy viewers use this, and they prefer CAPS, which | ||
213 | // we have, so this really never runs. | ||
214 | // Allow it, but only for "safe" types. | ||
215 | if ((InventoryType)item.InvType != InventoryType.Notecard && | ||
216 | (InventoryType)item.InvType != InventoryType.LSL) | ||
217 | return; | ||
218 | 163 | ||
219 | if (asset != null) | 164 | uploader.RequestUpdateTaskInventoryItem(remoteClient, item); |
220 | { | ||
221 | // m_log.DebugFormat( | ||
222 | // "[AGENT ASSETS TRANSACTIONS]: Updating item {0} in {1} for transaction {2}", | ||
223 | // item.Name, part.Name, transactionID); | ||
224 | |||
225 | asset.FullID = UUID.Random(); | ||
226 | asset.Name = item.Name; | ||
227 | asset.Description = item.Description; | ||
228 | asset.Type = (sbyte)item.Type; | ||
229 | item.AssetID = asset.FullID; | ||
230 | |||
231 | m_Scene.AssetService.Store(asset); | ||
232 | } | ||
233 | } | ||
234 | else | ||
235 | { | ||
236 | m_log.ErrorFormat( | ||
237 | "[AGENT ASSET TRANSACTIONS]: Could not find uploader with transaction ID {0} when handling request to update task inventory item {1} in {2}", | ||
238 | transactionID, item.Name, part.Name); | ||
239 | } | ||
240 | } | 165 | } |
241 | 166 | ||
242 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, | 167 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, |
243 | UUID transactionID, InventoryItemBase item) | 168 | UUID transactionID, InventoryItemBase item) |
244 | { | 169 | { |
245 | AssetXferUploader uploader = null; | 170 | AssetXferUploader uploader = RequestXferUploader(transactionID); |
246 | |||
247 | lock (XferUploaders) | ||
248 | { | ||
249 | if (XferUploaders.ContainsKey(transactionID)) | ||
250 | uploader = XferUploaders[transactionID]; | ||
251 | } | ||
252 | 171 | ||
253 | if (uploader != null) | 172 | uploader.RequestUpdateInventoryItem(remoteClient, item); |
254 | { | ||
255 | uploader.RequestUpdateInventoryItem(remoteClient, transactionID, item); | ||
256 | } | ||
257 | else | ||
258 | { | ||
259 | m_log.ErrorFormat( | ||
260 | "[AGENT ASSET TRANSACTIONS]: Could not find uploader with transaction ID {0} when handling request to update inventory item {1} for {2}", | ||
261 | transactionID, item.Name, remoteClient.Name); | ||
262 | } | ||
263 | } | 173 | } |
264 | } | 174 | } |
265 | } | 175 | } \ No newline at end of file |