aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs89
1 files changed, 57 insertions, 32 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 00af175..3cba9b4 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -299,7 +299,7 @@ namespace OpenSim.Region.CoreModules.Asset
299 } 299 }
300 catch (Exception e) 300 catch (Exception e)
301 { 301 {
302 m_log.ErrorFormat( 302 m_log.WarnFormat(
303 "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", 303 "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}",
304 asset.ID, e.Message, e.StackTrace); 304 asset.ID, e.Message, e.StackTrace);
305 } 305 }
@@ -339,12 +339,13 @@ namespace OpenSim.Region.CoreModules.Asset
339 /// Try to get an asset from the file cache. 339 /// Try to get an asset from the file cache.
340 /// </summary> 340 /// </summary>
341 /// <param name="id"></param> 341 /// <param name="id"></param>
342 /// <returns></returns> 342 /// <returns>An asset retrieved from the file cache. null if there was a problem retrieving an asset.</returns>
343 private AssetBase GetFromFileCache(string id) 343 private AssetBase GetFromFileCache(string id)
344 { 344 {
345 AssetBase asset = null; 345 AssetBase asset = null;
346 346
347 string filename = GetFileName(id); 347 string filename = GetFileName(id);
348
348 if (File.Exists(filename)) 349 if (File.Exists(filename))
349 { 350 {
350 FileStream stream = null; 351 FileStream stream = null;
@@ -359,7 +360,7 @@ namespace OpenSim.Region.CoreModules.Asset
359 } 360 }
360 catch (System.Runtime.Serialization.SerializationException e) 361 catch (System.Runtime.Serialization.SerializationException e)
361 { 362 {
362 m_log.ErrorFormat( 363 m_log.WarnFormat(
363 "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", 364 "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}",
364 filename, id, e.Message, e.StackTrace); 365 filename, id, e.Message, e.StackTrace);
365 366
@@ -371,7 +372,7 @@ namespace OpenSim.Region.CoreModules.Asset
371 } 372 }
372 catch (Exception e) 373 catch (Exception e)
373 { 374 {
374 m_log.ErrorFormat( 375 m_log.WarnFormat(
375 "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", 376 "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}",
376 filename, id, e.Message, e.StackTrace); 377 filename, id, e.Message, e.StackTrace);
377 } 378 }
@@ -469,7 +470,7 @@ namespace OpenSim.Region.CoreModules.Asset
469 } 470 }
470 catch (Exception e) 471 catch (Exception e)
471 { 472 {
472 m_log.ErrorFormat( 473 m_log.WarnFormat(
473 "[FLOTSAM ASSET CACHE]: Failed to expire cached file {0}. Exception {1} {2}", 474 "[FLOTSAM ASSET CACHE]: Failed to expire cached file {0}. Exception {1} {2}",
474 id, e.Message, e.StackTrace); 475 id, e.Message, e.StackTrace);
475 } 476 }
@@ -520,29 +521,39 @@ namespace OpenSim.Region.CoreModules.Asset
520 /// <param name="purgeLine"></param> 521 /// <param name="purgeLine"></param>
521 private void CleanExpiredFiles(string dir, DateTime purgeLine) 522 private void CleanExpiredFiles(string dir, DateTime purgeLine)
522 { 523 {
523 foreach (string file in Directory.GetFiles(dir)) 524 try
524 { 525 {
525 if (File.GetLastAccessTime(file) < purgeLine) 526 foreach (string file in Directory.GetFiles(dir))
526 { 527 {
527 File.Delete(file); 528 if (File.GetLastAccessTime(file) < purgeLine)
529 {
530 File.Delete(file);
531 }
528 } 532 }
529 }
530 533
531 // Recurse into lower tiers 534 // Recurse into lower tiers
532 foreach (string subdir in Directory.GetDirectories(dir)) 535 foreach (string subdir in Directory.GetDirectories(dir))
533 { 536 {
534 CleanExpiredFiles(subdir, purgeLine); 537 CleanExpiredFiles(subdir, purgeLine);
535 } 538 }
536 539
537 // Check if a tier directory is empty, if so, delete it 540 // Check if a tier directory is empty, if so, delete it
538 int dirSize = Directory.GetFiles(dir).Length + Directory.GetDirectories(dir).Length; 541 int dirSize = Directory.GetFiles(dir).Length + Directory.GetDirectories(dir).Length;
539 if (dirSize == 0) 542 if (dirSize == 0)
540 { 543 {
541 Directory.Delete(dir); 544 Directory.Delete(dir);
545 }
546 else if (dirSize >= m_CacheWarnAt)
547 {
548 m_log.WarnFormat(
549 "[FLOTSAM ASSET CACHE]: Cache folder exceeded CacheWarnAt limit {0} {1}. Suggest increasing tiers, tier length, or reducing cache expiration",
550 dir, dirSize);
551 }
542 } 552 }
543 else if (dirSize >= m_CacheWarnAt) 553 catch (Exception e)
544 { 554 {
545 m_log.WarnFormat("[FLOTSAM ASSET CACHE]: Cache folder exceeded CacheWarnAt limit {0} {1}. Suggest increasing tiers, tier length, or reducing cache expiration", dir, dirSize); 555 m_log.Warn(
556 string.Format("[FLOTSAM ASSET CACHE]: Could not complete clean of expired files in {0}, exception ", dir), e);
546 } 557 }
547 } 558 }
548 559
@@ -601,7 +612,7 @@ namespace OpenSim.Region.CoreModules.Asset
601 } 612 }
602 catch (IOException e) 613 catch (IOException e)
603 { 614 {
604 m_log.ErrorFormat( 615 m_log.WarnFormat(
605 "[FLOTSAM ASSET CACHE]: Failed to write asset {0} to temporary location {1} (final {2}) on cache in {3}. Exception {4} {5}.", 616 "[FLOTSAM ASSET CACHE]: Failed to write asset {0} to temporary location {1} (final {2}) on cache in {3}. Exception {4} {5}.",
606 asset.ID, tempname, filename, directory, e.Message, e.StackTrace); 617 asset.ID, tempname, filename, directory, e.Message, e.StackTrace);
607 618
@@ -680,17 +691,31 @@ namespace OpenSim.Region.CoreModules.Asset
680 /// <summary> 691 /// <summary>
681 /// This notes the last time the Region had a deep asset scan performed on it. 692 /// This notes the last time the Region had a deep asset scan performed on it.
682 /// </summary> 693 /// </summary>
683 /// <param name="RegionID"></param> 694 /// <param name="regionID"></param>
684 private void StampRegionStatusFile(UUID RegionID) 695 private void StampRegionStatusFile(UUID regionID)
685 { 696 {
686 string RegionCacheStatusFile = Path.Combine(m_CacheDirectory, "RegionStatus_" + RegionID.ToString() + ".fac"); 697 string RegionCacheStatusFile = Path.Combine(m_CacheDirectory, "RegionStatus_" + regionID.ToString() + ".fac");
687 if (File.Exists(RegionCacheStatusFile)) 698
699 try
688 { 700 {
689 File.SetLastWriteTime(RegionCacheStatusFile, DateTime.Now); 701 if (File.Exists(RegionCacheStatusFile))
702 {
703 File.SetLastWriteTime(RegionCacheStatusFile, DateTime.Now);
704 }
705 else
706 {
707 File.WriteAllText(
708 RegionCacheStatusFile,
709 "Please do not delete this file unless you are manually clearing your Flotsam Asset Cache.");
710 }
690 } 711 }
691 else 712 catch (Exception e)
692 { 713 {
693 File.WriteAllText(RegionCacheStatusFile, "Please do not delete this file unless you are manually clearing your Flotsam Asset Cache."); 714 m_log.Warn(
715 string.Format(
716 "[FLOTSAM ASSET CACHE]: Could not stamp region status file for region {0}. Exception ",
717 regionID),
718 e);
694 } 719 }
695 } 720 }
696 721
@@ -759,7 +784,7 @@ namespace OpenSim.Region.CoreModules.Asset
759 } 784 }
760 catch (Exception e) 785 catch (Exception e)
761 { 786 {
762 m_log.ErrorFormat( 787 m_log.WarnFormat(
763 "[FLOTSAM ASSET CACHE]: Couldn't clear asset cache directory {0} from {1}. Exception {2} {3}", 788 "[FLOTSAM ASSET CACHE]: Couldn't clear asset cache directory {0} from {1}. Exception {2} {3}",
764 dir, m_CacheDirectory, e.Message, e.StackTrace); 789 dir, m_CacheDirectory, e.Message, e.StackTrace);
765 } 790 }
@@ -773,7 +798,7 @@ namespace OpenSim.Region.CoreModules.Asset
773 } 798 }
774 catch (Exception e) 799 catch (Exception e)
775 { 800 {
776 m_log.ErrorFormat( 801 m_log.WarnFormat(
777 "[FLOTSAM ASSET CACHE]: Couldn't clear asset cache file {0} from {1}. Exception {1} {2}", 802 "[FLOTSAM ASSET CACHE]: Couldn't clear asset cache file {0} from {1}. Exception {1} {2}",
778 file, m_CacheDirectory, e.Message, e.StackTrace); 803 file, m_CacheDirectory, e.Message, e.StackTrace);
779 } 804 }