mod_managed: not crash when cannot remove shadow directory (this sometimes happens when restarting from FS console)

This commit is contained in:
Artur Kraev 2014-11-03 00:24:49 +03:00
parent 7c0cf506d8
commit f3d089a998
1 changed files with 13 additions and 3 deletions

View File

@ -64,13 +64,23 @@ namespace FreeSWITCH {
public static bool Load() {
managedDir = Path.Combine(Native.freeswitch.SWITCH_GLOBAL_dirs.mod_dir, "managed");
shadowDir = Path.Combine(managedDir, "shadow");
if (Directory.Exists(shadowDir)) {
Directory.Delete(shadowDir, true);
if (Directory.Exists(shadowDir))
{
try
{
Directory.Delete(shadowDir, true);
}
catch (Exception ex)
{
Log.WriteLine(LogLevel.Warning, "Cannot delete shadow directory: {0}", ex);
}
Directory.CreateDirectory(shadowDir);
}
Log.WriteLine(LogLevel.Debug, "FreeSWITCH.Managed loader is starting with directory '{0}'.", managedDir);
if (!Directory.Exists(managedDir)) {
if (!Directory.Exists(managedDir))
{
Log.WriteLine(LogLevel.Error, "Managed directory not found: {0}", managedDir);
return false;
}