diff options
author | Melanie Thielker | 2017-02-01 16:31:01 +0000 |
---|---|---|
committer | Melanie Thielker | 2017-02-01 16:31:01 +0000 |
commit | a5151bb337cfee14dff6045d7f8e293201ae94ac (patch) | |
tree | f301338415da7160e48efcb4dc6cd1efc7faecaf /OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |
parent | Secure sim stats with an (optional) password. (diff) | |
download | opensim-SC-a5151bb337cfee14dff6045d7f8e293201ae94ac.zip opensim-SC-a5151bb337cfee14dff6045d7f8e293201ae94ac.tar.gz opensim-SC-a5151bb337cfee14dff6045d7f8e293201ae94ac.tar.bz2 opensim-SC-a5151bb337cfee14dff6045d7f8e293201ae94ac.tar.xz |
Refactor asset handling as per Ubit's suggestion
Diffstat (limited to 'OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index b183a75..f8a4461 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -536,24 +536,23 @@ namespace OpenSim.Region.CoreModules.Asset | |||
536 | // For IAssetService | 536 | // For IAssetService |
537 | public AssetBase Get(string id) | 537 | public AssetBase Get(string id) |
538 | { | 538 | { |
539 | bool negative; | 539 | AssetBase asset; |
540 | return Get(id, out negative); | 540 | Get(id, out asset); |
541 | return asset; | ||
541 | } | 542 | } |
542 | 543 | ||
543 | public AssetBase Get(string id, out bool negative) | 544 | public bool Get(string id, out AssetBase asset) |
544 | { | 545 | { |
545 | negative = false; | 546 | asset = null; |
546 | 547 | ||
547 | m_Requests++; | 548 | m_Requests++; |
548 | 549 | ||
549 | object dummy; | 550 | object dummy; |
550 | if (m_negativeCache.TryGetValue(id, out dummy)) | 551 | if (m_negativeCache.TryGetValue(id, out dummy)) |
551 | { | 552 | { |
552 | negative = true; | 553 | return false; |
553 | return null; | ||
554 | } | 554 | } |
555 | 555 | ||
556 | AssetBase asset = null; | ||
557 | asset = GetFromWeakReference(id); | 556 | asset = GetFromWeakReference(id); |
558 | if (asset != null && m_updateFileTimeOnCacheHit) | 557 | if (asset != null && m_updateFileTimeOnCacheHit) |
559 | { | 558 | { |
@@ -592,7 +591,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
592 | GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l)); | 591 | GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l)); |
593 | } | 592 | } |
594 | 593 | ||
595 | return asset; | 594 | return true; |
596 | } | 595 | } |
597 | 596 | ||
598 | public bool Check(string id) | 597 | public bool Check(string id) |
@@ -607,8 +606,9 @@ namespace OpenSim.Region.CoreModules.Asset | |||
607 | 606 | ||
608 | public AssetBase GetCached(string id) | 607 | public AssetBase GetCached(string id) |
609 | { | 608 | { |
610 | bool negative; | 609 | AssetBase asset; |
611 | return Get(id, out negative); | 610 | Get(id, out asset); |
611 | return asset; | ||
612 | } | 612 | } |
613 | 613 | ||
614 | public void Expire(string id) | 614 | public void Expire(string id) |
@@ -1236,23 +1236,22 @@ namespace OpenSim.Region.CoreModules.Asset | |||
1236 | 1236 | ||
1237 | public AssetMetadata GetMetadata(string id) | 1237 | public AssetMetadata GetMetadata(string id) |
1238 | { | 1238 | { |
1239 | bool negative; | 1239 | AssetBase asset; |
1240 | AssetBase asset = Get(id, out negative); | 1240 | Get(id, out asset); |
1241 | return asset.Metadata; | 1241 | return asset.Metadata; |
1242 | } | 1242 | } |
1243 | 1243 | ||
1244 | public byte[] GetData(string id) | 1244 | public byte[] GetData(string id) |
1245 | { | 1245 | { |
1246 | bool negative; | 1246 | AssetBase asset; |
1247 | AssetBase asset = Get(id, out negative); | 1247 | Get(id, out asset); |
1248 | return asset.Data; | 1248 | return asset.Data; |
1249 | } | 1249 | } |
1250 | 1250 | ||
1251 | public bool Get(string id, object sender, AssetRetrieved handler) | 1251 | public bool Get(string id, object sender, AssetRetrieved handler) |
1252 | { | 1252 | { |
1253 | bool negative; | 1253 | AssetBase asset; |
1254 | AssetBase asset = Get(id, out negative); | 1254 | if (!Get(id, out asset)) |
1255 | if (negative) | ||
1256 | return false; | 1255 | return false; |
1257 | handler(id, sender, asset); | 1256 | handler(id, sender, asset); |
1258 | return true; | 1257 | return true; |
@@ -1284,8 +1283,9 @@ namespace OpenSim.Region.CoreModules.Asset | |||
1284 | 1283 | ||
1285 | public bool UpdateContent(string id, byte[] data) | 1284 | public bool UpdateContent(string id, byte[] data) |
1286 | { | 1285 | { |
1287 | bool negative; | 1286 | AssetBase asset; |
1288 | AssetBase asset = Get(id, out negative); | 1287 | if (!Get(id, out asset)) |
1288 | return false; | ||
1289 | asset.Data = data; | 1289 | asset.Data = data; |
1290 | Cache(asset); | 1290 | Cache(asset); |
1291 | return true; | 1291 | return true; |