|
|
@ -44,26 +44,40 @@ namespace NzbDrone.Common
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get
|
|
|
|
get
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var dir = new DirectoryInfo(Environment.CurrentDirectory);
|
|
|
|
string applicationPath;
|
|
|
|
|
|
|
|
|
|
|
|
while (!ContainsIIS(dir))
|
|
|
|
applicationPath = GetApplicationPath(Environment.CurrentDirectory);
|
|
|
|
{
|
|
|
|
if (!string.IsNullOrWhiteSpace(applicationPath))
|
|
|
|
if (dir.Parent == null) break;
|
|
|
|
return applicationPath;
|
|
|
|
dir = dir.Parent;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ContainsIIS(dir)) return dir.FullName;
|
|
|
|
applicationPath = GetApplicationPath(StartUpPath);
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(applicationPath))
|
|
|
|
|
|
|
|
return applicationPath;
|
|
|
|
|
|
|
|
|
|
|
|
dir = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory;
|
|
|
|
applicationPath = GetApplicationPath(NzbDronePathFromEnviroment);
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(applicationPath))
|
|
|
|
|
|
|
|
return applicationPath;
|
|
|
|
|
|
|
|
|
|
|
|
while (!ContainsIIS(dir))
|
|
|
|
throw new ApplicationException("Can't fine IISExpress folder.");
|
|
|
|
{
|
|
|
|
}
|
|
|
|
if (dir.Parent == null) throw new ApplicationException("Can't fine IISExpress folder.");
|
|
|
|
}
|
|
|
|
dir = dir.Parent;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return dir.FullName;
|
|
|
|
private string GetApplicationPath(string dir)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var directoryInfo = new DirectoryInfo(dir);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (!ContainsIIS(directoryInfo))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (directoryInfo.Parent == null) break;
|
|
|
|
|
|
|
|
directoryInfo = directoryInfo.Parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return directoryInfo.FullName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static bool ContainsIIS(DirectoryInfo dir)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return dir.GetDirectories(IIS_FOLDER_NAME).Length != 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -110,9 +124,14 @@ namespace NzbDrone.Common
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static bool ContainsIIS(DirectoryInfo dir)
|
|
|
|
public virtual string NzbDronePathFromEnviroment
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return dir.GetDirectories(IIS_FOLDER_NAME).Length != 0;
|
|
|
|
get
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Environment.GetEnvironmentVariable(NZBDRONE_PATH);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|