From 133e4f5ed3e70a9ae98e0c65d61981f7142703c2 Mon Sep 17 00:00:00 2001 From: artman41 Date: Thu, 17 May 2018 00:51:39 +0100 Subject: [PATCH] Small refactor so that files aren't copied if patch is up to date --- IPA/Program.cs | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/IPA/Program.cs b/IPA/Program.cs index eb839c17..6a4da9d8 100644 --- a/IPA/Program.cs +++ b/IPA/Program.cs @@ -80,26 +80,37 @@ namespace IPA var isCurrentNewer = Version.CompareTo(patchedModule.Data.Version) > 0; if (isCurrentNewer) { Console.ForegroundColor = ConsoleColor.White; - Console.WriteLine($"Preparing for update, {(patchedModule.Data.Version == null ? "UnPatched" : patchedModule.Data.Version.ToString())} => {Version}"); + Console.WriteLine( + $"Preparing for update, {(patchedModule.Data.Version == null ? "UnPatched" : patchedModule.Data.Version.ToString())} => {Version}"); Console.WriteLine("--- Starting ---"); - Revert(context, new []{"newVersion"}); + Revert(context, new[] {"newVersion"}); Console.ResetColor(); - } - - // Copying - Console.ForegroundColor = ConsoleColor.Magenta; - Console.WriteLine("Updating files... "); - var nativePluginFolder = Path.Combine(context.DataPathDst, "Plugins"); - bool isFlat = Directory.Exists(nativePluginFolder) && Directory.GetFiles(nativePluginFolder).Any(f => f.EndsWith(".dll")); - bool force = !BackupManager.HasBackup(context) || context.Args.Contains("-f") || context.Args.Contains("--force"); - var architecture = DetectArchitecture(context.Executable); - Console.WriteLine("Architecture: {0}", architecture); - CopyAll(new DirectoryInfo(context.DataPathSrc), new DirectoryInfo(context.DataPathDst), force, backup, - (from, to) => NativePluginInterceptor(from, to, new DirectoryInfo(nativePluginFolder), isFlat, architecture) ); + // Copying + Console.ForegroundColor = ConsoleColor.Magenta; + Console.WriteLine("Updating files... "); + var nativePluginFolder = Path.Combine(context.DataPathDst, "Plugins"); + bool isFlat = Directory.Exists(nativePluginFolder) && + Directory.GetFiles(nativePluginFolder).Any(f => f.EndsWith(".dll")); + bool force = !BackupManager.HasBackup(context) || context.Args.Contains("-f") || + context.Args.Contains("--force"); + var architecture = DetectArchitecture(context.Executable); + + Console.WriteLine("Architecture: {0}", architecture); + + CopyAll(new DirectoryInfo(context.DataPathSrc), new DirectoryInfo(context.DataPathDst), force, + backup, + (from, to) => NativePluginInterceptor(from, to, new DirectoryInfo(nativePluginFolder), isFlat, + architecture)); - Console.WriteLine("Successfully updated files!"); + Console.WriteLine("Successfully updated files!"); + } + else { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine($"Files up to date @ Version {Version}!"); + Console.ResetColor(); + } if (!Directory.Exists(context.PluginsFolder)) {