aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/AssetCache.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/AssetCache.cs')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs74
1 files changed, 14 insertions, 60 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index 69e0437..fddf01d 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -334,18 +334,9 @@ namespace OpenSim.Framework.Communications.Cache
334 /// <param name="asset"></param> 334 /// <param name="asset"></param>
335 public void AddAsset(AssetBase asset) 335 public void AddAsset(AssetBase asset)
336 { 336 {
337 string temporary = asset.Temporary ? "temporary" : String.Empty;
338 string type = asset.Type == 0 ? "texture" : "asset";
339
340 string result = "Ignored";
341
342 if (asset.Type == 0) 337 if (asset.Type == 0)
343 { 338 {
344 if (Textures.ContainsKey(asset.FullID)) 339 if (!Textures.ContainsKey(asset.FullID))
345 {
346 result = "Duplicate ignored.";
347 }
348 else
349 { 340 {
350 TextureImage textur = new TextureImage(asset); 341 TextureImage textur = new TextureImage(asset);
351 Textures.Add(textur.FullID, textur); 342 Textures.Add(textur.FullID, textur);
@@ -353,24 +344,15 @@ namespace OpenSim.Framework.Communications.Cache
353 if (StatsManager.SimExtraStats != null) 344 if (StatsManager.SimExtraStats != null)
354 StatsManager.SimExtraStats.AddTexture(textur); 345 StatsManager.SimExtraStats.AddTexture(textur);
355 346
356 if (asset.Temporary) 347 if (!asset.Temporary)
357 {
358 result = "Added to cache";
359 }
360 else
361 { 348 {
362 m_assetServer.StoreAndCommitAsset(asset); 349 m_assetServer.StoreAndCommitAsset(asset);
363 result = "Added to server";
364 } 350 }
365 } 351 }
366 } 352 }
367 else 353 else
368 { 354 {
369 if (Assets.ContainsKey(asset.FullID)) 355 if (!Assets.ContainsKey(asset.FullID))
370 {
371 result = "Duplicate ignored.";
372 }
373 else
374 { 356 {
375 AssetInfo assetInf = new AssetInfo(asset); 357 AssetInfo assetInf = new AssetInfo(asset);
376 Assets.Add(assetInf.FullID, assetInf); 358 Assets.Add(assetInf.FullID, assetInf);
@@ -378,29 +360,17 @@ namespace OpenSim.Framework.Communications.Cache
378 if (StatsManager.SimExtraStats != null) 360 if (StatsManager.SimExtraStats != null)
379 StatsManager.SimExtraStats.AddAsset(assetInf); 361 StatsManager.SimExtraStats.AddAsset(assetInf);
380 362
381 if (asset.Temporary) 363 if (!asset.Temporary)
382 {
383 result = "Added to cache";
384 }
385 else
386 { 364 {
387 m_assetServer.StoreAndCommitAsset(asset); 365 m_assetServer.StoreAndCommitAsset(asset);
388 result = "Added to server";
389 } 366 }
390 } 367 }
391 } 368 }
392#if DEBUG
393 //m_log.DebugFormat("[ASSET CACHE]: Adding {0} {1} [{2}]: {3}.", temporary, type, asset.FullID, result);
394#endif
395 } 369 }
396 370
397 // See IAssetReceiver 371 // See IAssetReceiver
398 public void AssetReceived(AssetBase asset, bool IsTexture) 372 public void AssetReceived(AssetBase asset, bool IsTexture)
399 { 373 {
400#if DEBUG
401 //m_log.DebugFormat("[ASSET CACHE]: Received {0} [{1}]", IsTexture ? "texture" : "asset", asset.FullID);
402#endif
403
404 if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server 374 if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server
405 { 375 {
406 //check if it is a texture or not 376 //check if it is a texture or not
@@ -411,13 +381,7 @@ namespace OpenSim.Framework.Communications.Cache
411 if (IsTexture) 381 if (IsTexture)
412 { 382 {
413 TextureImage image = new TextureImage(asset); 383 TextureImage image = new TextureImage(asset);
414 if (Textures.ContainsKey(image.FullID)) 384 if (!Textures.ContainsKey(image.FullID))
415 {
416#if DEBUG
417 //m_log.DebugFormat("[ASSET CACHE]: There's already an texture {0} in memory. Skipping.", asset.FullID);
418#endif
419 }
420 else
421 { 385 {
422 Textures.Add(image.FullID, image); 386 Textures.Add(image.FullID, image);
423 387
@@ -430,13 +394,7 @@ namespace OpenSim.Framework.Communications.Cache
430 else 394 else
431 { 395 {
432 AssetInfo assetInf = new AssetInfo(asset); 396 AssetInfo assetInf = new AssetInfo(asset);
433 if (Assets.ContainsKey(assetInf.FullID)) 397 if (!Assets.ContainsKey(assetInf.FullID))
434 {
435#if DEBUG
436 //m_log.DebugFormat("[ASSET CACHE]: There's already an asset {0} in memory. Skipping.", asset.FullID);
437#endif
438 }
439 else
440 { 398 {
441 Assets.Add(assetInf.FullID, assetInf); 399 Assets.Add(assetInf.FullID, assetInf);
442 400
@@ -446,18 +404,14 @@ namespace OpenSim.Framework.Communications.Cache
446 } 404 }
447 405
448 if (RequestedAssets.ContainsKey(assetInf.FullID)) 406 if (RequestedAssets.ContainsKey(assetInf.FullID))
449 { 407 {
450 #if DEBUG 408 AssetRequest req = RequestedAssets[assetInf.FullID];
451 //m_log.DebugFormat("[ASSET CACHE]: Moving {0} from RequestedAssets to AssetRequests", asset.FullID); 409 req.AssetInf = assetInf;
452 #endif 410 req.NumPackets = CalculateNumPackets(assetInf.Data);
453 411
454 AssetRequest req = RequestedAssets[assetInf.FullID]; 412 RequestedAssets.Remove(assetInf.FullID);
455 req.AssetInf = assetInf; 413 AssetRequests.Add(req);
456 req.NumPackets = CalculateNumPackets(assetInf.Data); 414 }
457
458 RequestedAssets.Remove(assetInf.FullID);
459 AssetRequests.Add(req);
460 }
461 } 415 }
462 } 416 }
463 417