|
|
@ -22,29 +22,23 @@ namespace Ombi.Updater
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Kill Ombi Process
|
|
|
|
// Kill Ombi Process
|
|
|
|
var p = new ProcessProvider();
|
|
|
|
var p = new ProcessProvider();
|
|
|
|
|
|
|
|
bool killed = false;
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p.Kill(opt);
|
|
|
|
killed = p.Kill(opt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Console.WriteLine(e);
|
|
|
|
Console.WriteLine(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Make sure the process has been killed
|
|
|
|
if (!killed)
|
|
|
|
while (p.FindProcessByName(opt.ProcessName).Any())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
|
|
|
_log.LogDebug("Found another process called {0}, KILLING!", opt.ProcessName);
|
|
|
|
_log.LogDebug("Couldn't kill the ombi process");
|
|
|
|
var proc = p.FindProcessByName(opt.ProcessName).FirstOrDefault();
|
|
|
|
return;
|
|
|
|
if (proc != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_log.LogDebug($"[{proc.Id}] - {proc.Name} - Path: {proc.StartPath}");
|
|
|
|
|
|
|
|
opt.OmbiProcessId = proc.Id;
|
|
|
|
|
|
|
|
p.Kill(opt);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_log.LogDebug("Starting to move the files");
|
|
|
|
_log.LogDebug("Starting to move the files");
|
|
|
@ -111,21 +105,23 @@ namespace Ombi.Updater
|
|
|
|
var location = System.Reflection.Assembly.GetEntryAssembly().Location;
|
|
|
|
var location = System.Reflection.Assembly.GetEntryAssembly().Location;
|
|
|
|
location = Path.GetDirectoryName(location);
|
|
|
|
location = Path.GetDirectoryName(location);
|
|
|
|
_log.LogDebug("We are currently in dir {0}", location);
|
|
|
|
_log.LogDebug("We are currently in dir {0}", location);
|
|
|
|
|
|
|
|
var updatedLocation = Directory.GetParent(location).FullName;
|
|
|
|
|
|
|
|
_log.LogDebug("The files are in {0}", updatedLocation);
|
|
|
|
_log.LogDebug("Ombi is installed at {0}", options.ApplicationPath);
|
|
|
|
_log.LogDebug("Ombi is installed at {0}", options.ApplicationPath);
|
|
|
|
|
|
|
|
|
|
|
|
//Now Create all of the directories
|
|
|
|
//Now Create all of the directories
|
|
|
|
foreach (string dirPath in Directory.GetDirectories(location, "*",
|
|
|
|
foreach (string dirPath in Directory.GetDirectories(updatedLocation, "*",
|
|
|
|
SearchOption.AllDirectories))
|
|
|
|
SearchOption.AllDirectories))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var newDir = dirPath.Replace(location, options.ApplicationPath);
|
|
|
|
var newDir = dirPath.Replace(updatedLocation, options.ApplicationPath);
|
|
|
|
Directory.CreateDirectory(newDir);
|
|
|
|
Directory.CreateDirectory(newDir);
|
|
|
|
_log.LogDebug("Created dir {0}", newDir);
|
|
|
|
_log.LogDebug("Created dir {0}", newDir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Copy all the files & Replaces any files with the same name
|
|
|
|
//Copy all the files & Replaces any files with the same name
|
|
|
|
foreach (string currentPath in Directory.GetFiles(location, "*.*",
|
|
|
|
foreach (string currentPath in Directory.GetFiles(updatedLocation, "*.*",
|
|
|
|
SearchOption.AllDirectories))
|
|
|
|
SearchOption.AllDirectories))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var newFile = currentPath.Replace(location, options.ApplicationPath);
|
|
|
|
var newFile = currentPath.Replace(updatedLocation, options.ApplicationPath);
|
|
|
|
File.Copy(currentPath, newFile, true);
|
|
|
|
File.Copy(currentPath, newFile, true);
|
|
|
|
_log.LogDebug("Replaced file {0}", newFile);
|
|
|
|
_log.LogDebug("Replaced file {0}", newFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|