mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-30 11:38:32 -07:00
More work on the Updater
This commit is contained in:
parent
dcf97a1008
commit
d9be265abe
8 changed files with 187 additions and 4 deletions
|
@ -1,5 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Ombi.Updater
|
||||
|
@ -13,8 +16,49 @@ namespace Ombi.Updater
|
|||
|
||||
p.Kill(options.OmbiProcessId);
|
||||
|
||||
|
||||
// Make sure the process has been killed
|
||||
if (p.FindProcessByName("Ombi").Any())
|
||||
{
|
||||
// throw
|
||||
}
|
||||
|
||||
MoveFiles(options);
|
||||
|
||||
// Start Ombi
|
||||
StartOmbi(options);
|
||||
}
|
||||
|
||||
|
||||
private void StartOmbi(StartupOptions options)
|
||||
{
|
||||
var start = new ProcessStartInfo
|
||||
{
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
FileName = Path.Combine(options.ApplicationPath,"Ombi.exe")
|
||||
};
|
||||
using (var proc = new Process { StartInfo = start })
|
||||
{
|
||||
proc.Start();
|
||||
}
|
||||
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private void MoveFiles(StartupOptions options)
|
||||
{
|
||||
var location = System.Reflection.Assembly.GetEntryAssembly().Location;
|
||||
location = Path.GetDirectoryName(location);
|
||||
|
||||
//Now Create all of the directories
|
||||
foreach (string dirPath in Directory.GetDirectories(location, "*",
|
||||
SearchOption.AllDirectories))
|
||||
Directory.CreateDirectory(dirPath.Replace(location, options.ApplicationPath));
|
||||
|
||||
//Copy all the files & Replaces any files with the same name
|
||||
foreach (string newPath in Directory.GetFiles(location, "*.*",
|
||||
SearchOption.AllDirectories))
|
||||
File.Copy(newPath, newPath.Replace(location, options.ApplicationPath), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue