diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent')
3 files changed, 184 insertions, 187 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 | } |
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs index 441c4ff..4bb8986 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 = |
@@ -274,13 +274,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
274 | } | 274 | } |
275 | 275 | ||
276 | AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); | 276 | AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); |
277 | AssetXferUploader uploader = transactions.RequestXferUploader(transaction, assetID); | 277 | AssetXferUploader uploader = transactions.RequestXferUploader(transaction); |
278 | 278 | uploader.StartUpload(remoteClient, assetID, transaction, type, data, storeLocal, tempFile); | |
279 | if (uploader != null) | ||
280 | { | ||
281 | uploader.Initialise(remoteClient, assetID, transaction, type, | ||
282 | data, storeLocal, tempFile); | ||
283 | } | ||
284 | } | 279 | } |
285 | 280 | ||
286 | /// <summary> | 281 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index 4cedfe6..f6dd5af 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs | |||
@@ -49,39 +49,75 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 50 | ||
51 | /// <summary> | 51 | /// <summary> |
52 | /// Upload state. | ||
53 | /// </summary> | ||
54 | /// <remarks> | ||
55 | /// New -> Uploading -> Complete | ||
56 | /// </remarks> | ||
57 | private enum UploadState | ||
58 | { | ||
59 | New, | ||
60 | Uploading, | ||
61 | Complete | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
52 | /// Reference to the object that holds this uploader. Used to remove ourselves from it's list if we | 65 | /// Reference to the object that holds this uploader. Used to remove ourselves from it's list if we |
53 | /// are performing a delayed update. | 66 | /// are performing a delayed update. |
54 | /// </summary> | 67 | /// </summary> |
55 | AgentAssetTransactions m_transactions; | 68 | AgentAssetTransactions m_transactions; |
56 | 69 | ||
70 | private UploadState m_uploadState = UploadState.New; | ||
71 | |||
57 | private AssetBase m_asset; | 72 | private AssetBase m_asset; |
58 | private UUID InventFolder = UUID.Zero; | 73 | private UUID InventFolder = UUID.Zero; |
59 | private sbyte invType = 0; | 74 | private sbyte invType = 0; |
60 | 75 | ||
61 | private bool m_createItem = false; | 76 | private bool m_createItem; |
62 | private uint m_createItemCallback = 0; | 77 | private uint m_createItemCallback; |
63 | private bool m_updateItem = false; | 78 | |
79 | private bool m_updateItem; | ||
64 | private InventoryItemBase m_updateItemData; | 80 | private InventoryItemBase m_updateItemData; |
65 | 81 | ||
82 | private bool m_updateTaskItem; | ||
83 | private TaskInventoryItem m_updateTaskItemData; | ||
84 | |||
66 | private string m_description = String.Empty; | 85 | private string m_description = String.Empty; |
67 | private bool m_dumpAssetToFile; | 86 | private bool m_dumpAssetToFile; |
68 | private bool m_finished = false; | ||
69 | private string m_name = String.Empty; | 87 | private string m_name = String.Empty; |
70 | private bool m_storeLocal; | 88 | // private bool m_storeLocal; |
71 | private uint nextPerm = 0; | 89 | private uint nextPerm = 0; |
72 | private IClientAPI ourClient; | 90 | private IClientAPI ourClient; |
73 | private UUID TransactionID = UUID.Zero; | 91 | |
92 | private UUID m_transactionID; | ||
93 | |||
74 | private sbyte type = 0; | 94 | private sbyte type = 0; |
75 | private byte wearableType = 0; | 95 | private byte wearableType = 0; |
76 | private byte[] m_oldData = null; | 96 | private byte[] m_oldData = null; |
77 | public ulong XferID; | 97 | public ulong XferID; |
78 | private Scene m_Scene; | 98 | private Scene m_Scene; |
79 | 99 | ||
80 | public AssetXferUploader(AgentAssetTransactions transactions, Scene scene, UUID assetID, bool dumpAssetToFile) | 100 | /// <summary> |
101 | /// AssetXferUploader constructor | ||
102 | /// </summary> | ||
103 | /// <param name='transactions'>/param> | ||
104 | /// <param name='scene'></param> | ||
105 | /// <param name='transactionID'></param> | ||
106 | /// <param name='dumpAssetToFile'> | ||
107 | /// If true then when the asset is uploaded it is dumped to a file with the format | ||
108 | /// String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", | ||
109 | /// now.Year, now.Month, now.Day, now.Hour, now.Minute, | ||
110 | /// now.Second, m_asset.Name, m_asset.Type); | ||
111 | /// for debugging purposes. | ||
112 | /// </param> | ||
113 | public AssetXferUploader( | ||
114 | AgentAssetTransactions transactions, Scene scene, UUID transactionID, bool dumpAssetToFile) | ||
81 | { | 115 | { |
116 | m_asset = new AssetBase(); | ||
117 | |||
82 | m_transactions = transactions; | 118 | m_transactions = transactions; |
119 | m_transactionID = transactionID; | ||
83 | m_Scene = scene; | 120 | m_Scene = scene; |
84 | m_asset = new AssetBase() { FullID = assetID }; | ||
85 | m_dumpAssetToFile = dumpAssetToFile; | 121 | m_dumpAssetToFile = dumpAssetToFile; |
86 | } | 122 | } |
87 | 123 | ||
@@ -127,30 +163,50 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
127 | } | 163 | } |
128 | 164 | ||
129 | /// <summary> | 165 | /// <summary> |
130 | /// Initialise asset transfer from the client | 166 | /// Start asset transfer from the client |
131 | /// </summary> | 167 | /// </summary> |
132 | /// <param name="xferID"></param> | 168 | /// <param name="remoteClient"></param> |
133 | /// <param name="packetID"></param> | 169 | /// <param name="assetID"></param> |
134 | /// <param name="data"></param> | 170 | /// <param name="transaction"></param> |
135 | public void Initialise(IClientAPI remoteClient, UUID assetID, | 171 | /// <param name="type"></param> |
136 | UUID transaction, sbyte type, byte[] data, bool storeLocal, | 172 | /// <param name="data"> |
137 | bool tempFile) | 173 | /// Optional data. If present then the asset is created immediately with this data |
174 | /// rather than requesting an upload from the client. The data must be longer than 2 bytes. | ||
175 | /// </param> | ||
176 | /// <param name="storeLocal"></param> | ||
177 | /// <param name="tempFile"></param> | ||
178 | public void StartUpload( | ||
179 | IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, byte[] data, bool storeLocal, | ||
180 | bool tempFile) | ||
138 | { | 181 | { |
139 | // m_log.DebugFormat( | 182 | // m_log.DebugFormat( |
140 | // "[ASSET XFER UPLOADER]: Initialised xfer from {0}, asset {1}, transaction {2}, type {3}, storeLocal {4}, tempFile {5}, already received data length {6}", | 183 | // "[ASSET XFER UPLOADER]: Initialised xfer from {0}, asset {1}, transaction {2}, type {3}, storeLocal {4}, tempFile {5}, already received data length {6}", |
141 | // remoteClient.Name, assetID, transaction, type, storeLocal, tempFile, data.Length); | 184 | // remoteClient.Name, assetID, transaction, type, storeLocal, tempFile, data.Length); |
142 | 185 | ||
186 | lock (this) | ||
187 | { | ||
188 | if (m_uploadState != UploadState.New) | ||
189 | { | ||
190 | m_log.WarnFormat( | ||
191 | "[ASSET XFER UPLOADER]: Tried to start upload of asset {0}, transaction {1} for {2} but this is already in state {3}. Aborting.", | ||
192 | assetID, transaction, remoteClient.Name, m_uploadState); | ||
193 | |||
194 | return; | ||
195 | } | ||
196 | |||
197 | m_uploadState = UploadState.Uploading; | ||
198 | } | ||
199 | |||
143 | ourClient = remoteClient; | 200 | ourClient = remoteClient; |
144 | m_asset.Name = "blank"; | 201 | |
145 | m_asset.Description = "empty"; | 202 | m_asset.FullID = assetID; |
146 | m_asset.Type = type; | 203 | m_asset.Type = type; |
147 | m_asset.CreatorID = remoteClient.AgentId.ToString(); | 204 | m_asset.CreatorID = remoteClient.AgentId.ToString(); |
148 | m_asset.Data = data; | 205 | m_asset.Data = data; |
149 | m_asset.Local = storeLocal; | 206 | m_asset.Local = storeLocal; |
150 | m_asset.Temporary = tempFile; | 207 | m_asset.Temporary = tempFile; |
151 | 208 | ||
152 | TransactionID = transaction; | 209 | // m_storeLocal = storeLocal; |
153 | m_storeLocal = storeLocal; | ||
154 | 210 | ||
155 | if (m_asset.Data.Length > 2) | 211 | if (m_asset.Data.Length > 2) |
156 | { | 212 | { |
@@ -175,36 +231,35 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
175 | 231 | ||
176 | protected void SendCompleteMessage() | 232 | protected void SendCompleteMessage() |
177 | { | 233 | { |
178 | ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, | ||
179 | m_asset.FullID); | ||
180 | |||
181 | // We must lock in order to avoid a race with a separate thread dealing with an inventory item or create | 234 | // We must lock in order to avoid a race with a separate thread dealing with an inventory item or create |
182 | // message from other client UDP. | 235 | // message from other client UDP. |
183 | lock (this) | 236 | lock (this) |
184 | { | 237 | { |
185 | m_finished = true; | 238 | m_uploadState = UploadState.Complete; |
239 | |||
240 | ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, m_asset.FullID); | ||
241 | |||
186 | if (m_createItem) | 242 | if (m_createItem) |
187 | { | 243 | { |
188 | DoCreateItem(m_createItemCallback); | 244 | CompleteCreateItem(m_createItemCallback); |
189 | } | 245 | } |
190 | else if (m_updateItem) | 246 | else if (m_updateItem) |
191 | { | 247 | { |
192 | StoreAssetForItemUpdate(m_updateItemData); | 248 | CompleteItemUpdate(m_updateItemData); |
193 | |||
194 | // Remove ourselves from the list of transactions if completion was delayed until the transaction | ||
195 | // was complete. | ||
196 | // TODO: Should probably do the same for create item. | ||
197 | m_transactions.RemoveXferUploader(TransactionID); | ||
198 | } | 249 | } |
199 | else if (m_storeLocal) | 250 | else if (m_updateTaskItem) |
200 | { | 251 | { |
201 | m_Scene.AssetService.Store(m_asset); | 252 | CompleteTaskItemUpdate(m_updateTaskItemData); |
202 | } | 253 | } |
254 | // else if (m_storeLocal) | ||
255 | // { | ||
256 | // m_Scene.AssetService.Store(m_asset); | ||
257 | // } | ||
203 | } | 258 | } |
204 | 259 | ||
205 | m_log.DebugFormat( | 260 | m_log.DebugFormat( |
206 | "[ASSET XFER UPLOADER]: Uploaded asset {0} for transaction {1}", | 261 | "[ASSET XFER UPLOADER]: Uploaded asset {0} for transaction {1}", |
207 | m_asset.FullID, TransactionID); | 262 | m_asset.FullID, m_transactionID); |
208 | 263 | ||
209 | if (m_dumpAssetToFile) | 264 | if (m_dumpAssetToFile) |
210 | { | 265 | { |
@@ -232,40 +287,37 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
232 | } | 287 | } |
233 | 288 | ||
234 | public void RequestCreateInventoryItem(IClientAPI remoteClient, | 289 | public void RequestCreateInventoryItem(IClientAPI remoteClient, |
235 | UUID transactionID, UUID folderID, uint callbackID, | 290 | UUID folderID, uint callbackID, |
236 | string description, string name, sbyte invType, | 291 | string description, string name, sbyte invType, |
237 | sbyte type, byte wearableType, uint nextOwnerMask) | 292 | sbyte type, byte wearableType, uint nextOwnerMask) |
238 | { | 293 | { |
239 | if (TransactionID == transactionID) | 294 | InventFolder = folderID; |
295 | m_name = name; | ||
296 | m_description = description; | ||
297 | this.type = type; | ||
298 | this.invType = invType; | ||
299 | this.wearableType = wearableType; | ||
300 | nextPerm = nextOwnerMask; | ||
301 | m_asset.Name = name; | ||
302 | m_asset.Description = description; | ||
303 | m_asset.Type = type; | ||
304 | |||
305 | // We must lock to avoid a race with a separate thread uploading the asset. | ||
306 | lock (this) | ||
240 | { | 307 | { |
241 | InventFolder = folderID; | 308 | if (m_uploadState == UploadState.Complete) |
242 | m_name = name; | ||
243 | m_description = description; | ||
244 | this.type = type; | ||
245 | this.invType = invType; | ||
246 | this.wearableType = wearableType; | ||
247 | nextPerm = nextOwnerMask; | ||
248 | m_asset.Name = name; | ||
249 | m_asset.Description = description; | ||
250 | m_asset.Type = type; | ||
251 | |||
252 | // We must lock to avoid a race with a separate thread uploading the asset. | ||
253 | lock (this) | ||
254 | { | 309 | { |
255 | if (m_finished) | 310 | CompleteCreateItem(callbackID); |
256 | { | 311 | } |
257 | DoCreateItem(callbackID); | 312 | else |
258 | } | 313 | { |
259 | else | 314 | m_createItem = true; //set flag so the inventory item is created when upload is complete |
260 | { | 315 | m_createItemCallback = callbackID; |
261 | m_createItem = true; //set flag so the inventory item is created when upload is complete | ||
262 | m_createItemCallback = callbackID; | ||
263 | } | ||
264 | } | 316 | } |
265 | } | 317 | } |
266 | } | 318 | } |
267 | 319 | ||
268 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, UUID transactionID, InventoryItemBase item) | 320 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, InventoryItemBase item) |
269 | { | 321 | { |
270 | // We must lock to avoid a race with a separate thread uploading the asset. | 322 | // We must lock to avoid a race with a separate thread uploading the asset. |
271 | lock (this) | 323 | lock (this) |
@@ -280,9 +332,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
280 | item.AssetID = m_asset.FullID; | 332 | item.AssetID = m_asset.FullID; |
281 | m_Scene.InventoryService.UpdateItem(item); | 333 | m_Scene.InventoryService.UpdateItem(item); |
282 | 334 | ||
283 | if (m_finished) | 335 | if (m_uploadState == UploadState.Complete) |
284 | { | 336 | { |
285 | StoreAssetForItemUpdate(item); | 337 | CompleteItemUpdate(item); |
286 | } | 338 | } |
287 | else | 339 | else |
288 | { | 340 | { |
@@ -296,20 +348,59 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
296 | } | 348 | } |
297 | } | 349 | } |
298 | 350 | ||
351 | public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, TaskInventoryItem taskItem) | ||
352 | { | ||
353 | // We must lock to avoid a race with a separate thread uploading the asset. | ||
354 | lock (this) | ||
355 | { | ||
356 | m_asset.Name = taskItem.Name; | ||
357 | m_asset.Description = taskItem.Description; | ||
358 | m_asset.Type = (sbyte)taskItem.Type; | ||
359 | taskItem.AssetID = m_asset.FullID; | ||
360 | |||
361 | if (m_uploadState == UploadState.Complete) | ||
362 | { | ||
363 | CompleteTaskItemUpdate(taskItem); | ||
364 | } | ||
365 | else | ||
366 | { | ||
367 | m_updateTaskItem = true; | ||
368 | m_updateTaskItemData = taskItem; | ||
369 | } | ||
370 | } | ||
371 | } | ||
372 | |||
299 | /// <summary> | 373 | /// <summary> |
300 | /// Store the asset for the given item. | 374 | /// Store the asset for the given item when it has been uploaded. |
301 | /// </summary> | 375 | /// </summary> |
302 | /// <param name="item"></param> | 376 | /// <param name="item"></param> |
303 | private void StoreAssetForItemUpdate(InventoryItemBase item) | 377 | private void CompleteItemUpdate(InventoryItemBase item) |
304 | { | 378 | { |
305 | // m_log.DebugFormat( | 379 | // m_log.DebugFormat( |
306 | // "[ASSET XFER UPLOADER]: Storing asset {0} for earlier item update for {1} for {2}", | 380 | // "[ASSET XFER UPLOADER]: Storing asset {0} for earlier item update for {1} for {2}", |
307 | // m_asset.FullID, item.Name, ourClient.Name); | 381 | // m_asset.FullID, item.Name, ourClient.Name); |
308 | 382 | ||
309 | m_Scene.AssetService.Store(m_asset); | 383 | m_Scene.AssetService.Store(m_asset); |
384 | |||
385 | m_transactions.RemoveXferUploader(m_transactionID); | ||
386 | } | ||
387 | |||
388 | /// <summary> | ||
389 | /// Store the asset for the given task item when it has been uploaded. | ||
390 | /// </summary> | ||
391 | /// <param name="taskItem"></param> | ||
392 | private void CompleteTaskItemUpdate(TaskInventoryItem taskItem) | ||
393 | { | ||
394 | // m_log.DebugFormat( | ||
395 | // "[ASSET XFER UPLOADER]: Storing asset {0} for earlier task item update for {1} for {2}", | ||
396 | // m_asset.FullID, taskItem.Name, ourClient.Name); | ||
397 | |||
398 | m_Scene.AssetService.Store(m_asset); | ||
399 | |||
400 | m_transactions.RemoveXferUploader(m_transactionID); | ||
310 | } | 401 | } |
311 | 402 | ||
312 | private void DoCreateItem(uint callbackID) | 403 | private void CompleteCreateItem(uint callbackID) |
313 | { | 404 | { |
314 | ValidateAssets(); | 405 | ValidateAssets(); |
315 | m_Scene.AssetService.Store(m_asset); | 406 | m_Scene.AssetService.Store(m_asset); |
@@ -339,6 +430,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
339 | ourClient.SendInventoryItemCreateUpdate(item, callbackID); | 430 | ourClient.SendInventoryItemCreateUpdate(item, callbackID); |
340 | else | 431 | else |
341 | ourClient.SendAlertMessage("Unable to create inventory item"); | 432 | ourClient.SendAlertMessage("Unable to create inventory item"); |
433 | |||
434 | m_transactions.RemoveXferUploader(m_transactionID); | ||
342 | } | 435 | } |
343 | 436 | ||
344 | private void ValidateAssets() | 437 | private void ValidateAssets() |
@@ -416,7 +509,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
416 | /// <returns>null if the asset has not finished uploading</returns> | 509 | /// <returns>null if the asset has not finished uploading</returns> |
417 | public AssetBase GetAssetData() | 510 | public AssetBase GetAssetData() |
418 | { | 511 | { |
419 | if (m_finished) | 512 | if (m_uploadState == UploadState.Complete) |
420 | { | 513 | { |
421 | ValidateAssets(); | 514 | ValidateAssets(); |
422 | return m_asset; | 515 | return m_asset; |
@@ -469,4 +562,3 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
469 | } | 562 | } |
470 | } | 563 | } |
471 | } | 564 | } |
472 | |||