refactoring
This commit is contained in:
parent
d0743d66a0
commit
1fa39a3885
3 changed files with 19 additions and 41 deletions
|
@ -78,25 +78,9 @@ internal partial class InstallForm : CustomForm
|
|||
foreach (string directory in await selection.GetKoaloaderDirectories())
|
||||
{
|
||||
directory.GetKoaloaderComponents(out List<string> proxies, out string config);
|
||||
bool proxyExists = false;
|
||||
foreach (string proxy in proxies)
|
||||
if (File.Exists(proxy) && proxy.IsResourceFile(Resources.Resources.ResourceIdentifier.Koaloader))
|
||||
{
|
||||
proxyExists = true;
|
||||
break;
|
||||
}
|
||||
bool dllExists = proxyExists || false;
|
||||
if (!dllExists)
|
||||
foreach ((string unlocker, string dll) in Koaloader.AutoLoadDlls)
|
||||
{
|
||||
string path = directory + @"\" + dll;
|
||||
if (File.Exists(path))
|
||||
{
|
||||
dllExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (proxyExists || dllExists || File.Exists(config))
|
||||
if (proxies.Any(proxy => File.Exists(proxy) && proxy.IsResourceFile(Resources.Resources.ResourceIdentifier.Koaloader))
|
||||
|| Koaloader.AutoLoadDlls.Any(pair => File.Exists(directory + @"\" + pair.dll))
|
||||
|| File.Exists(config))
|
||||
{
|
||||
UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation);
|
||||
await Koaloader.Uninstall(directory, this);
|
||||
|
|
|
@ -72,8 +72,8 @@ internal partial class MainForm : CustomForm
|
|||
if (checkForUpdatesResult.CanUpdate)
|
||||
{
|
||||
#endif
|
||||
latestVersion = checkForUpdatesResult.LastVersion;
|
||||
versions = checkForUpdatesResult.Versions;
|
||||
latestVersion = checkForUpdatesResult.LastVersion;
|
||||
versions = checkForUpdatesResult.Versions;
|
||||
#if !DEBUG
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -18,12 +18,11 @@ internal static class Koaloader
|
|||
)
|
||||
{
|
||||
proxies = new();
|
||||
foreach (string proxy in Resources.EmbeddedResources)
|
||||
foreach (string proxy in Resources.EmbeddedResources.Select(proxy =>
|
||||
{
|
||||
string proxyPath = proxy[(proxy.IndexOf('.') + 1)..];
|
||||
proxyPath = proxyPath[(proxyPath.IndexOf('.') + 1)..];
|
||||
proxies.Add(directory + @"\" + proxyPath);
|
||||
}
|
||||
proxy = proxy[(proxy.IndexOf('.') + 1)..];
|
||||
return proxy[(proxy.IndexOf('.') + 1)..];
|
||||
})) proxies.Add(directory + @"\" + proxy);
|
||||
config = directory + @"\Koaloader.json";
|
||||
}
|
||||
|
||||
|
@ -101,24 +100,19 @@ internal static class Koaloader
|
|||
internal static async Task Uninstall(string directory, InstallForm installForm = null, bool deleteConfig = true) => await Task.Run(() =>
|
||||
{
|
||||
directory.GetKoaloaderComponents(out List<string> proxies, out string config);
|
||||
foreach (string proxy in proxies)
|
||||
foreach (string proxy in proxies.Where(proxy => File.Exists(proxy) && proxy.IsResourceFile(Resources.ResourceIdentifier.Koaloader)))
|
||||
{
|
||||
if (File.Exists(proxy) && proxy.IsResourceFile(Resources.ResourceIdentifier.Koaloader))
|
||||
{
|
||||
File.Delete(proxy);
|
||||
if (installForm is not null)
|
||||
installForm.UpdateUser($"Deleted Koaloader: {Path.GetFileName(proxy)}", InstallationLog.Action, info: false);
|
||||
}
|
||||
File.Delete(proxy);
|
||||
if (installForm is not null)
|
||||
installForm.UpdateUser($"Deleted Koaloader: {Path.GetFileName(proxy)}", InstallationLog.Action, info: false);
|
||||
}
|
||||
foreach ((string unlocker, string dll) in AutoLoadDlls)
|
||||
foreach ((string unlocker, string path) in AutoLoadDlls
|
||||
.Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll))
|
||||
.Where(pair => File.Exists(pair.path)))
|
||||
{
|
||||
string path = directory + @"\" + dll;
|
||||
if (File.Exists(path))
|
||||
{
|
||||
File.Delete(path);
|
||||
if (installForm is not null)
|
||||
installForm.UpdateUser($"Deleted {unlocker}: {Path.GetFileName(path)}", InstallationLog.Action, info: false);
|
||||
}
|
||||
File.Delete(path);
|
||||
if (installForm is not null)
|
||||
installForm.UpdateUser($"Deleted {unlocker}: {Path.GetFileName(path)}", InstallationLog.Action, info: false);
|
||||
}
|
||||
if (deleteConfig && File.Exists(config))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue