mantis 8181: don't try to delete contents of a non exitent folder

0.9.0-post-fixes
UbitUmarov 2017-05-26 05:32:59 +01:00
parent 426f2130fc
commit 8f10db0a6a
1 changed files with 13 additions and 4 deletions

View File

@ -646,7 +646,7 @@ namespace OpenSim.Region.CoreModules.Asset
if (m_LogLevel >= 2) if (m_LogLevel >= 2)
m_log.Debug("[FLOTSAM ASSET CACHE]: Clearing caches."); m_log.Debug("[FLOTSAM ASSET CACHE]: Clearing caches.");
if (m_FileCacheEnabled) if (m_FileCacheEnabled && Directory.Exists(m_CacheDirectory))
{ {
foreach (string dir in Directory.GetDirectories(m_CacheDirectory)) foreach (string dir in Directory.GetDirectories(m_CacheDirectory))
{ {
@ -681,10 +681,10 @@ namespace OpenSim.Region.CoreModules.Asset
// before cleaning up expired files we must scan the objects in the scene to make sure that we retain // before cleaning up expired files we must scan the objects in the scene to make sure that we retain
// such local assets if they have not been recently accessed. // such local assets if they have not been recently accessed.
TouchAllSceneAssets(false); TouchAllSceneAssets(false);
if(Directory.Exists(m_CacheDirectory))
foreach (string dir in Directory.GetDirectories(m_CacheDirectory))
{ {
CleanExpiredFiles(dir, purgeLine); foreach (string dir in Directory.GetDirectories(m_CacheDirectory))
CleanExpiredFiles(dir, purgeLine);
} }
lock(timerLock) lock(timerLock)
@ -706,6 +706,9 @@ namespace OpenSim.Region.CoreModules.Asset
{ {
try try
{ {
if(!Directory.Exists(dir))
return;
foreach (string file in Directory.GetFiles(dir)) foreach (string file in Directory.GetFiles(dir))
{ {
if (File.GetLastAccessTime(file) < purgeLine) if (File.GetLastAccessTime(file) < purgeLine)
@ -869,6 +872,9 @@ namespace OpenSim.Region.CoreModules.Asset
/// <returns></returns> /// <returns></returns>
private int GetFileCacheCount(string dir) private int GetFileCacheCount(string dir)
{ {
if(!Directory.Exists(dir))
return 0;
int count = Directory.GetFiles(dir).Length; int count = Directory.GetFiles(dir).Length;
foreach (string subdir in Directory.GetDirectories(dir)) foreach (string subdir in Directory.GetDirectories(dir))
@ -987,6 +993,9 @@ namespace OpenSim.Region.CoreModules.Asset
/// </summary> /// </summary>
private void ClearFileCache() private void ClearFileCache()
{ {
if(!Directory.Exists(m_CacheDirectory))
return;
foreach (string dir in Directory.GetDirectories(m_CacheDirectory)) foreach (string dir in Directory.GetDirectories(m_CacheDirectory))
{ {
try try