diff options
author | BlueWall | 2012-09-25 18:14:06 -0400 |
---|---|---|
committer | BlueWall | 2012-09-25 18:14:06 -0400 |
commit | 4dc27aa91fd8316071b6e2dc6336ce4aceb97399 (patch) | |
tree | 93db0bb10994e27812ea969a59eb4364a58c7f50 /OpenSim/Region/CoreModules | |
parent | Format OpenSim.ini.example (diff) | |
parent | Comment out old m_storeLocal from AssetXferUploader. (diff) | |
download | opensim-SC_OLD-4dc27aa91fd8316071b6e2dc6336ce4aceb97399.zip opensim-SC_OLD-4dc27aa91fd8316071b6e2dc6336ce4aceb97399.tar.gz opensim-SC_OLD-4dc27aa91fd8316071b6e2dc6336ce4aceb97399.tar.bz2 opensim-SC_OLD-4dc27aa91fd8316071b6e2dc6336ce4aceb97399.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/CoreModules')
3 files changed, 174 insertions, 189 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 |
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs index 7081989..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 = |
@@ -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 ec4dfd0..8d21202 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs | |||
@@ -41,38 +41,72 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
42 | 42 | ||
43 | /// <summary> | 43 | /// <summary> |
44 | /// Upload state. | ||
45 | /// </summary> | ||
46 | /// <remarks> | ||
47 | /// New -> Uploading -> Complete | ||
48 | /// </remarks> | ||
49 | private enum UploadState | ||
50 | { | ||
51 | New, | ||
52 | Uploading, | ||
53 | Complete | ||
54 | } | ||
55 | |||
56 | /// <summary> | ||
44 | /// Reference to the object that holds this uploader. Used to remove ourselves from it's list if we | 57 | /// Reference to the object that holds this uploader. Used to remove ourselves from it's list if we |
45 | /// are performing a delayed update. | 58 | /// are performing a delayed update. |
46 | /// </summary> | 59 | /// </summary> |
47 | AgentAssetTransactions m_transactions; | 60 | AgentAssetTransactions m_transactions; |
48 | 61 | ||
62 | private UploadState m_uploadState = UploadState.New; | ||
63 | |||
49 | private AssetBase m_asset; | 64 | private AssetBase m_asset; |
50 | private UUID InventFolder = UUID.Zero; | 65 | private UUID InventFolder = UUID.Zero; |
51 | private sbyte invType = 0; | 66 | private sbyte invType = 0; |
52 | 67 | ||
53 | private bool m_createItem = false; | 68 | private bool m_createItem; |
54 | private uint m_createItemCallback = 0; | 69 | private uint m_createItemCallback; |
55 | private bool m_updateItem = false; | 70 | |
71 | private bool m_updateItem; | ||
56 | private InventoryItemBase m_updateItemData; | 72 | private InventoryItemBase m_updateItemData; |
57 | 73 | ||
74 | private bool m_updateTaskItem; | ||
75 | private TaskInventoryItem m_updateTaskItemData; | ||
76 | |||
58 | private string m_description = String.Empty; | 77 | private string m_description = String.Empty; |
59 | private bool m_dumpAssetToFile; | 78 | private bool m_dumpAssetToFile; |
60 | private bool m_finished = false; | ||
61 | private string m_name = String.Empty; | 79 | private string m_name = String.Empty; |
62 | private bool m_storeLocal; | 80 | // private bool m_storeLocal; |
63 | private uint nextPerm = 0; | 81 | private uint nextPerm = 0; |
64 | private IClientAPI ourClient; | 82 | private IClientAPI ourClient; |
65 | private UUID TransactionID = UUID.Zero; | 83 | |
84 | private UUID m_transactionID; | ||
85 | |||
66 | private sbyte type = 0; | 86 | private sbyte type = 0; |
67 | private byte wearableType = 0; | 87 | private byte wearableType = 0; |
68 | public ulong XferID; | 88 | public ulong XferID; |
69 | private Scene m_Scene; | 89 | private Scene m_Scene; |
70 | 90 | ||
71 | public AssetXferUploader(AgentAssetTransactions transactions, Scene scene, UUID assetID, bool dumpAssetToFile) | 91 | /// <summary> |
92 | /// AssetXferUploader constructor | ||
93 | /// </summary> | ||
94 | /// <param name='transactions'>/param> | ||
95 | /// <param name='scene'></param> | ||
96 | /// <param name='transactionID'></param> | ||
97 | /// <param name='dumpAssetToFile'> | ||
98 | /// If true then when the asset is uploaded it is dumped to a file with the format | ||
99 | /// String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", | ||
100 | /// now.Year, now.Month, now.Day, now.Hour, now.Minute, | ||
101 | /// now.Second, m_asset.Name, m_asset.Type); | ||
102 | /// for debugging purposes. | ||
103 | /// </param> | ||
104 | public AssetXferUploader( | ||
105 | AgentAssetTransactions transactions, Scene scene, UUID transactionID, bool dumpAssetToFile) | ||
72 | { | 106 | { |
73 | m_transactions = transactions; | 107 | m_transactions = transactions; |
108 | m_transactionID = transactionID; | ||
74 | m_Scene = scene; | 109 | m_Scene = scene; |
75 | m_asset = new AssetBase() { FullID = assetID }; | ||
76 | m_dumpAssetToFile = dumpAssetToFile; | 110 | m_dumpAssetToFile = dumpAssetToFile; |
77 | } | 111 | } |
78 | 112 | ||
@@ -118,20 +152,43 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
118 | } | 152 | } |
119 | 153 | ||
120 | /// <summary> | 154 | /// <summary> |
121 | /// Initialise asset transfer from the client | 155 | /// Start asset transfer from the client |
122 | /// </summary> | 156 | /// </summary> |
123 | /// <param name="xferID"></param> | 157 | /// <param name="remoteClient"></param> |
124 | /// <param name="packetID"></param> | 158 | /// <param name="assetID"></param> |
125 | /// <param name="data"></param> | 159 | /// <param name="transaction"></param> |
126 | public void Initialise(IClientAPI remoteClient, UUID assetID, | 160 | /// <param name="type"></param> |
127 | UUID transaction, sbyte type, byte[] data, bool storeLocal, | 161 | /// <param name="data"> |
128 | bool tempFile) | 162 | /// Optional data. If present then the asset is created immediately with this data |
163 | /// rather than requesting an upload from the client. The data must be longer than 2 bytes. | ||
164 | /// </param> | ||
165 | /// <param name="storeLocal"></param> | ||
166 | /// <param name="tempFile"></param> | ||
167 | public void StartUpload( | ||
168 | IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, byte[] data, bool storeLocal, | ||
169 | bool tempFile) | ||
129 | { | 170 | { |
130 | // m_log.DebugFormat( | 171 | // m_log.DebugFormat( |
131 | // "[ASSET XFER UPLOADER]: Initialised xfer from {0}, asset {1}, transaction {2}, type {3}, storeLocal {4}, tempFile {5}, already received data length {6}", | 172 | // "[ASSET XFER UPLOADER]: Initialised xfer from {0}, asset {1}, transaction {2}, type {3}, storeLocal {4}, tempFile {5}, already received data length {6}", |
132 | // remoteClient.Name, assetID, transaction, type, storeLocal, tempFile, data.Length); | 173 | // remoteClient.Name, assetID, transaction, type, storeLocal, tempFile, data.Length); |
133 | 174 | ||
175 | lock (this) | ||
176 | { | ||
177 | if (m_uploadState != UploadState.New) | ||
178 | { | ||
179 | m_log.WarnFormat( | ||
180 | "[ASSET XFER UPLOADER]: Tried to start upload of asset {0}, transaction {1} for {2} but this is already in state {3}. Aborting.", | ||
181 | assetID, transaction, remoteClient.Name, m_uploadState); | ||
182 | |||
183 | return; | ||
184 | } | ||
185 | |||
186 | m_uploadState = UploadState.Uploading; | ||
187 | } | ||
188 | |||
134 | ourClient = remoteClient; | 189 | ourClient = remoteClient; |
190 | |||
191 | m_asset = new AssetBase() { FullID = assetID }; | ||
135 | m_asset.Name = "blank"; | 192 | m_asset.Name = "blank"; |
136 | m_asset.Description = "empty"; | 193 | m_asset.Description = "empty"; |
137 | m_asset.Type = type; | 194 | m_asset.Type = type; |
@@ -140,8 +197,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
140 | m_asset.Local = storeLocal; | 197 | m_asset.Local = storeLocal; |
141 | m_asset.Temporary = tempFile; | 198 | m_asset.Temporary = tempFile; |
142 | 199 | ||
143 | TransactionID = transaction; | 200 | // m_storeLocal = storeLocal; |
144 | m_storeLocal = storeLocal; | ||
145 | 201 | ||
146 | if (m_asset.Data.Length > 2) | 202 | if (m_asset.Data.Length > 2) |
147 | { | 203 | { |
@@ -166,14 +222,14 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
166 | 222 | ||
167 | protected void SendCompleteMessage() | 223 | protected void SendCompleteMessage() |
168 | { | 224 | { |
169 | ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, | ||
170 | m_asset.FullID); | ||
171 | |||
172 | // We must lock in order to avoid a race with a separate thread dealing with an inventory item or create | 225 | // We must lock in order to avoid a race with a separate thread dealing with an inventory item or create |
173 | // message from other client UDP. | 226 | // message from other client UDP. |
174 | lock (this) | 227 | lock (this) |
175 | { | 228 | { |
176 | m_finished = true; | 229 | m_uploadState = UploadState.Complete; |
230 | |||
231 | ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, m_asset.FullID); | ||
232 | |||
177 | if (m_createItem) | 233 | if (m_createItem) |
178 | { | 234 | { |
179 | DoCreateItem(m_createItemCallback); | 235 | DoCreateItem(m_createItemCallback); |
@@ -185,17 +241,23 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
185 | // Remove ourselves from the list of transactions if completion was delayed until the transaction | 241 | // Remove ourselves from the list of transactions if completion was delayed until the transaction |
186 | // was complete. | 242 | // was complete. |
187 | // TODO: Should probably do the same for create item. | 243 | // TODO: Should probably do the same for create item. |
188 | m_transactions.RemoveXferUploader(TransactionID); | 244 | m_transactions.RemoveXferUploader(m_transactionID); |
189 | } | 245 | } |
190 | else if (m_storeLocal) | 246 | else if (m_updateTaskItem) |
191 | { | 247 | { |
192 | m_Scene.AssetService.Store(m_asset); | 248 | StoreAssetForTaskItemUpdate(m_updateTaskItemData); |
249 | |||
250 | m_transactions.RemoveXferUploader(m_transactionID); | ||
193 | } | 251 | } |
252 | // else if (m_storeLocal) | ||
253 | // { | ||
254 | // m_Scene.AssetService.Store(m_asset); | ||
255 | // } | ||
194 | } | 256 | } |
195 | 257 | ||
196 | m_log.DebugFormat( | 258 | m_log.DebugFormat( |
197 | "[ASSET XFER UPLOADER]: Uploaded asset {0} for transaction {1}", | 259 | "[ASSET XFER UPLOADER]: Uploaded asset {0} for transaction {1}", |
198 | m_asset.FullID, TransactionID); | 260 | m_asset.FullID, m_transactionID); |
199 | 261 | ||
200 | if (m_dumpAssetToFile) | 262 | if (m_dumpAssetToFile) |
201 | { | 263 | { |
@@ -223,40 +285,37 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
223 | } | 285 | } |
224 | 286 | ||
225 | public void RequestCreateInventoryItem(IClientAPI remoteClient, | 287 | public void RequestCreateInventoryItem(IClientAPI remoteClient, |
226 | UUID transactionID, UUID folderID, uint callbackID, | 288 | UUID folderID, uint callbackID, |
227 | string description, string name, sbyte invType, | 289 | string description, string name, sbyte invType, |
228 | sbyte type, byte wearableType, uint nextOwnerMask) | 290 | sbyte type, byte wearableType, uint nextOwnerMask) |
229 | { | 291 | { |
230 | if (TransactionID == transactionID) | 292 | InventFolder = folderID; |
293 | m_name = name; | ||
294 | m_description = description; | ||
295 | this.type = type; | ||
296 | this.invType = invType; | ||
297 | this.wearableType = wearableType; | ||
298 | nextPerm = nextOwnerMask; | ||
299 | m_asset.Name = name; | ||
300 | m_asset.Description = description; | ||
301 | m_asset.Type = type; | ||
302 | |||
303 | // We must lock to avoid a race with a separate thread uploading the asset. | ||
304 | lock (this) | ||
231 | { | 305 | { |
232 | InventFolder = folderID; | 306 | if (m_uploadState == UploadState.Complete) |
233 | m_name = name; | ||
234 | m_description = description; | ||
235 | this.type = type; | ||
236 | this.invType = invType; | ||
237 | this.wearableType = wearableType; | ||
238 | nextPerm = nextOwnerMask; | ||
239 | m_asset.Name = name; | ||
240 | m_asset.Description = description; | ||
241 | m_asset.Type = type; | ||
242 | |||
243 | // We must lock to avoid a race with a separate thread uploading the asset. | ||
244 | lock (this) | ||
245 | { | 307 | { |
246 | if (m_finished) | 308 | DoCreateItem(callbackID); |
247 | { | 309 | } |
248 | DoCreateItem(callbackID); | 310 | else |
249 | } | 311 | { |
250 | else | 312 | m_createItem = true; //set flag so the inventory item is created when upload is complete |
251 | { | 313 | m_createItemCallback = callbackID; |
252 | m_createItem = true; //set flag so the inventory item is created when upload is complete | ||
253 | m_createItemCallback = callbackID; | ||
254 | } | ||
255 | } | 314 | } |
256 | } | 315 | } |
257 | } | 316 | } |
258 | 317 | ||
259 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, UUID transactionID, InventoryItemBase item) | 318 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, InventoryItemBase item) |
260 | { | 319 | { |
261 | // We must lock to avoid a race with a separate thread uploading the asset. | 320 | // We must lock to avoid a race with a separate thread uploading the asset. |
262 | lock (this) | 321 | lock (this) |
@@ -271,7 +330,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
271 | item.AssetID = m_asset.FullID; | 330 | item.AssetID = m_asset.FullID; |
272 | m_Scene.InventoryService.UpdateItem(item); | 331 | m_Scene.InventoryService.UpdateItem(item); |
273 | 332 | ||
274 | if (m_finished) | 333 | if (m_uploadState == UploadState.Complete) |
275 | { | 334 | { |
276 | StoreAssetForItemUpdate(item); | 335 | StoreAssetForItemUpdate(item); |
277 | } | 336 | } |
@@ -287,8 +346,30 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
287 | } | 346 | } |
288 | } | 347 | } |
289 | 348 | ||
349 | public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, TaskInventoryItem taskItem) | ||
350 | { | ||
351 | // We must lock to avoid a race with a separate thread uploading the asset. | ||
352 | lock (this) | ||
353 | { | ||
354 | m_asset.Name = taskItem.Name; | ||
355 | m_asset.Description = taskItem.Description; | ||
356 | m_asset.Type = (sbyte)taskItem.Type; | ||
357 | taskItem.AssetID = m_asset.FullID; | ||
358 | |||
359 | if (m_uploadState == UploadState.Complete) | ||
360 | { | ||
361 | StoreAssetForTaskItemUpdate(taskItem); | ||
362 | } | ||
363 | else | ||
364 | { | ||
365 | m_updateTaskItem = true; | ||
366 | m_updateTaskItemData = taskItem; | ||
367 | } | ||
368 | } | ||
369 | } | ||
370 | |||
290 | /// <summary> | 371 | /// <summary> |
291 | /// Store the asset for the given item. | 372 | /// Store the asset for the given item when it has been uploaded. |
292 | /// </summary> | 373 | /// </summary> |
293 | /// <param name="item"></param> | 374 | /// <param name="item"></param> |
294 | private void StoreAssetForItemUpdate(InventoryItemBase item) | 375 | private void StoreAssetForItemUpdate(InventoryItemBase item) |
@@ -300,6 +381,19 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
300 | m_Scene.AssetService.Store(m_asset); | 381 | m_Scene.AssetService.Store(m_asset); |
301 | } | 382 | } |
302 | 383 | ||
384 | /// <summary> | ||
385 | /// Store the asset for the given task item when it has been uploaded. | ||
386 | /// </summary> | ||
387 | /// <param name="taskItem"></param> | ||
388 | private void StoreAssetForTaskItemUpdate(TaskInventoryItem taskItem) | ||
389 | { | ||
390 | // m_log.DebugFormat( | ||
391 | // "[ASSET XFER UPLOADER]: Storing asset {0} for earlier task item update for {1} for {2}", | ||
392 | // m_asset.FullID, taskItem.Name, ourClient.Name); | ||
393 | |||
394 | m_Scene.AssetService.Store(m_asset); | ||
395 | } | ||
396 | |||
303 | private void DoCreateItem(uint callbackID) | 397 | private void DoCreateItem(uint callbackID) |
304 | { | 398 | { |
305 | m_Scene.AssetService.Store(m_asset); | 399 | m_Scene.AssetService.Store(m_asset); |
@@ -327,19 +421,5 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
327 | else | 421 | else |
328 | ourClient.SendAlertMessage("Unable to create inventory item"); | 422 | ourClient.SendAlertMessage("Unable to create inventory item"); |
329 | } | 423 | } |
330 | |||
331 | /// <summary> | ||
332 | /// Get the asset data uploaded in this transfer. | ||
333 | /// </summary> | ||
334 | /// <returns>null if the asset has not finished uploading</returns> | ||
335 | public AssetBase GetAssetData() | ||
336 | { | ||
337 | if (m_finished) | ||
338 | { | ||
339 | return m_asset; | ||
340 | } | ||
341 | |||
342 | return null; | ||
343 | } | ||
344 | } | 424 | } |
345 | } | 425 | } \ No newline at end of file |