diff options
author | Oren Hurvitz | 2014-03-31 11:53:12 +0300 |
---|---|---|
committer | Oren Hurvitz | 2014-04-02 06:30:57 +0100 |
commit | d1c3f8eef58b29eb8760eeb1ac03852a2387f927 (patch) | |
tree | b8686f4ea01b6dac3740b9685734686e2178dd2d /OpenSim/Region/CoreModules/Framework | |
parent | fix orphaned code in sun module per mantis 7068 (diff) | |
download | opensim-SC-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.zip opensim-SC-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.tar.gz opensim-SC-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.tar.bz2 opensim-SC-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.tar.xz |
Added assets service method AssetsExist(), which returns whether the given list of assets exist.
This method is used to optimize sending assets with embedded assets: e.g., when a Hypergrid visitor takes an item into the inventory.
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | 69 |
1 files changed, 49 insertions, 20 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index d4fb1ba..532bc74 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | |||
@@ -145,11 +145,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
145 | string id = m_scene.AssetService.Store(asset1); | 145 | string id = m_scene.AssetService.Store(asset1); |
146 | if (id == string.Empty) | 146 | if (id == string.Empty) |
147 | { | 147 | { |
148 | m_log.DebugFormat("[HG ASSET MAPPER]: Asset server {0} did not accept {1}", url, asset.ID); | 148 | m_log.DebugFormat("[HG ASSET MAPPER]: Failed to post asset {0} to asset server {1}: the server did not accept the asset", asset.ID, url); |
149 | success = false; | 149 | success = false; |
150 | } | 150 | } |
151 | else | 151 | else |
152 | m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); | 152 | m_log.DebugFormat("[HG ASSET MAPPER]: Posted asset {0} to asset server {1}", asset1.ID, url); |
153 | } | 153 | } |
154 | return success; | 154 | return success; |
155 | } | 155 | } |
@@ -279,36 +279,65 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
279 | 279 | ||
280 | public void Post(UUID assetID, UUID ownerID, string userAssetURL) | 280 | public void Post(UUID assetID, UUID ownerID, string userAssetURL) |
281 | { | 281 | { |
282 | // Post the item from the local AssetCache onto the remote asset server | 282 | m_log.DebugFormat("[HG ASSET MAPPER]: Starting to send asset {0} with children to asset server {1}", assetID, userAssetURL); |
283 | // and place an entry in m_assetMap | 283 | |
284 | // Find all the embedded assets | ||
284 | 285 | ||
285 | m_log.Debug("[HG ASSET MAPPER]: Posting object " + assetID + " to asset server " + userAssetURL); | ||
286 | AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); | 286 | AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); |
287 | if (asset != null) | 287 | if (asset == null) |
288 | { | 288 | { |
289 | Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); | 289 | m_log.DebugFormat("[HG ASSET MAPPER]: Something wrong with asset {0}, it could not be found", assetID); |
290 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); | 290 | return; |
291 | uuidGatherer.GatherAssetUuids(asset.FullID, asset.Type, ids); | 291 | } |
292 | bool success = false; | 292 | |
293 | foreach (UUID uuid in ids.Keys) | 293 | Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); |
294 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); | ||
295 | uuidGatherer.GatherAssetUuids(asset.FullID, asset.Type, ids); | ||
296 | |||
297 | // Check which assets already exist in the destination server | ||
298 | |||
299 | string url = userAssetURL; | ||
300 | if (!url.EndsWith("/") && !url.EndsWith("=")) | ||
301 | url = url + "/"; | ||
302 | |||
303 | string[] remoteAssetIDs = new string[ids.Count]; | ||
304 | int i = 0; | ||
305 | foreach (UUID id in ids.Keys) | ||
306 | remoteAssetIDs[i++] = url + id.ToString(); | ||
307 | |||
308 | bool[] exist = m_scene.AssetService.AssetsExist(remoteAssetIDs); | ||
309 | |||
310 | var existSet = new HashSet<string>(); | ||
311 | i = 0; | ||
312 | foreach (UUID id in ids.Keys) | ||
313 | { | ||
314 | if (exist[i]) | ||
315 | existSet.Add(id.ToString()); | ||
316 | ++i; | ||
317 | } | ||
318 | |||
319 | // Send only those assets which don't already exist in the destination server | ||
320 | |||
321 | bool success = true; | ||
322 | |||
323 | foreach (UUID uuid in ids.Keys) | ||
324 | { | ||
325 | if (!existSet.Contains(uuid.ToString())) | ||
294 | { | 326 | { |
295 | asset = m_scene.AssetService.Get(uuid.ToString()); | 327 | asset = m_scene.AssetService.Get(uuid.ToString()); |
296 | if (asset == null) | 328 | if (asset == null) |
297 | m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid); | 329 | m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid); |
298 | else | 330 | else |
299 | success = PostAsset(userAssetURL, asset); | 331 | success &= PostAsset(userAssetURL, asset); |
300 | } | 332 | } |
301 | |||
302 | // maybe all pieces got there... | ||
303 | if (!success) | ||
304 | m_log.DebugFormat("[HG ASSET MAPPER]: Problems posting item {0} to asset server {1}", assetID, userAssetURL); | ||
305 | else | 333 | else |
306 | m_log.DebugFormat("[HG ASSET MAPPER]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL); | 334 | m_log.DebugFormat("[HG ASSET MAPPER]: Didn't post asset {0} because it already exists in asset server {1}", uuid, userAssetURL); |
307 | |||
308 | } | 335 | } |
309 | else | ||
310 | m_log.DebugFormat("[HG ASSET MAPPER]: Something wrong with asset {0}, it could not be found", assetID); | ||
311 | 336 | ||
337 | if (!success) | ||
338 | m_log.DebugFormat("[HG ASSET MAPPER]: Problems sending asset {0} with children to asset server {1}", assetID, userAssetURL); | ||
339 | else | ||
340 | m_log.DebugFormat("[HG ASSET MAPPER]: Successfully sent asset {0} with children to asset server {1}", assetID, userAssetURL); | ||
312 | } | 341 | } |
313 | 342 | ||
314 | #endregion | 343 | #endregion |