diff --git a/.gitattributes b/.gitattributes index 7e1b6a4..f5a9565 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ /Patcher/_port/Patcher/PatchGenerator/Resources/PatchClient.exe filter=lfs diff=lfs merge=lfs -text /Patcher/PatcherUtils/Resources/PatchClient.exe filter=lfs diff=lfs merge=lfs -text +/Patcher/PatchGenerator/Resources/PatchClient.exe filter=lfs diff=lfs merge=lfs -text diff --git a/Patcher/PatchClient/PatchClient.csproj b/Patcher/PatchClient/PatchClient.csproj index 55eb282..46f10e9 100644 --- a/Patcher/PatchClient/PatchClient.csproj +++ b/Patcher/PatchClient/PatchClient.csproj @@ -9,10 +9,6 @@ - - - - diff --git a/Patcher/PatchClient/Resources/xdelta3.exe b/Patcher/PatchClient/Resources/xdelta3.exe deleted file mode 100644 index 1cce3c5..0000000 Binary files a/Patcher/PatchClient/Resources/xdelta3.exe and /dev/null differ diff --git a/Patcher/PatchClient/ViewModels/PatcherViewModel.cs b/Patcher/PatchClient/ViewModels/PatcherViewModel.cs index 7e0a26b..11e5c18 100644 --- a/Patcher/PatchClient/ViewModels/PatcherViewModel.cs +++ b/Patcher/PatchClient/ViewModels/PatcherViewModel.cs @@ -5,8 +5,10 @@ using PatcherUtils; using ReactiveUI; using System; using System.Collections.ObjectModel; +using System.IO; using System.Linq; using System.Reactive.Disposables; +using System.Reflection; using System.Threading.Tasks; namespace PatchClient.ViewModels @@ -85,12 +87,18 @@ namespace PatchClient.ViewModels { Task.Run(async() => { + LazyOperations.ExtractResourcesToTempDir(Assembly.GetExecutingAssembly()); + PatchHelper patcher = new PatchHelper(Environment.CurrentDirectory, null, LazyOperations.PatchFolder); patcher.ProgressChanged += patcher_ProgressChanged; string message = patcher.ApplyPatches(); + LazyOperations.CleanupTempDir(); + + Directory.Delete(LazyOperations.PatchFolder, true); + await NavigateToWithDelay(new MessageViewModel(HostScreen, message), 400); }); } diff --git a/Patcher/PatchGenerator/PatchGenerator.csproj b/Patcher/PatchGenerator/PatchGenerator.csproj index 1a7bea1..11470f1 100644 --- a/Patcher/PatchGenerator/PatchGenerator.csproj +++ b/Patcher/PatchGenerator/PatchGenerator.csproj @@ -20,6 +20,13 @@ + + + + + + + diff --git a/Patcher/PatcherUtils/Resources/7za.exe b/Patcher/PatchGenerator/Resources/7za.exe similarity index 100% rename from Patcher/PatcherUtils/Resources/7za.exe rename to Patcher/PatchGenerator/Resources/7za.exe diff --git a/Patcher/PatchGenerator/Resources/PatchClient.exe b/Patcher/PatchGenerator/Resources/PatchClient.exe new file mode 100644 index 0000000..263d14c --- /dev/null +++ b/Patcher/PatchGenerator/Resources/PatchClient.exe @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3713f9732769cb32379c8a8765c90c5f27d7f7e03c8e95fd079f4ccc8ae6282a +size 25319084 diff --git a/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs b/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs index cae708b..c69de1a 100644 --- a/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs +++ b/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs @@ -9,6 +9,7 @@ using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Reactive.Disposables; +using System.Reflection; using System.Text; using System.Threading.Tasks; @@ -68,6 +69,8 @@ namespace PatchGenerator.ViewModels { string patchOutputFolder = Path.Join(generationInfo.PatchName.FromCwd(), LazyOperations.PatchFolder); + LazyOperations.ExtractResourcesToTempDir(Assembly.GetExecutingAssembly()); + PatchHelper patcher = new PatchHelper(generationInfo.SourceFolderPath, generationInfo.TargetFolderPath, patchOutputFolder); patcher.ProgressChanged += Patcher_ProgressChanged; diff --git a/Patcher/PatcherUtils/LazyOperations.cs b/Patcher/PatcherUtils/LazyOperations.cs index c4a69e8..ae87916 100644 --- a/Patcher/PatcherUtils/LazyOperations.cs +++ b/Patcher/PatcherUtils/LazyOperations.cs @@ -43,7 +43,7 @@ namespace PatcherUtils /// /// /// The resource will not be streamed out if the already exists - private static void StreamResourceOut(string ResourceName, string OutputFilePath) + private static void StreamResourceOut(Assembly assembly, string ResourceName, string OutputFilePath) { FileInfo outputFile = new FileInfo(OutputFilePath); @@ -55,7 +55,7 @@ namespace PatcherUtils } using (FileStream fs = File.Create(OutputFilePath)) - using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(ResourceName)) + using (Stream s = assembly.GetManifestResourceStream(ResourceName)) { s.CopyTo(fs); } @@ -64,25 +64,27 @@ namespace PatcherUtils /// /// Checks the resources in the assembly and streams them to the temp directory for later use. /// - public static void PrepTempDir() + public static void ExtractResourcesToTempDir(Assembly assembly = null) { - foreach (string resource in Assembly.GetExecutingAssembly().GetManifestResourceNames()) + if(assembly == null) assembly = Assembly.GetExecutingAssembly(); + + foreach (string resource in assembly.GetManifestResourceNames()) { switch (resource) { case string a when a.EndsWith(SevenZExe): { - StreamResourceOut(resource, SevenZExePath); + StreamResourceOut(assembly, resource, SevenZExePath); break; } case string a when a.EndsWith(PatcherClient): { - StreamResourceOut(resource, PatcherClientPath); + StreamResourceOut(assembly, resource, PatcherClientPath); break; } case string a when a.EndsWith(XDelta3EXE): { - StreamResourceOut(resource, XDelta3Path); + StreamResourceOut(assembly, resource, XDelta3Path); break; } } diff --git a/Patcher/PatcherUtils/PatchHelper.cs b/Patcher/PatcherUtils/PatchHelper.cs index f672ae7..d9221a2 100644 --- a/Patcher/PatcherUtils/PatchHelper.cs +++ b/Patcher/PatcherUtils/PatchHelper.cs @@ -180,8 +180,7 @@ namespace PatcherUtils return false; } - LazyOperations.CleanupTempDir(); - LazyOperations.PrepTempDir(); + LazyOperations.ExtractResourcesToTempDir(); List SourceFiles = sourceDir.GetFiles("*", SearchOption.AllDirectories).ToList(); @@ -280,8 +279,7 @@ namespace PatcherUtils return "One of the supplied directories doesn't exist"; } - LazyOperations.CleanupTempDir(); - LazyOperations.PrepTempDir(); + LazyOperations.ExtractResourcesToTempDir(); List SourceFiles = sourceDir.GetFiles("*", SearchOption.AllDirectories).ToList(); @@ -360,10 +358,6 @@ namespace PatcherUtils RaiseProgressChanged(filesProcessed, fileCountTotal, deltaFile.Name, AdditionalInfo.ToArray()); } - LazyOperations.CleanupTempDir(); - - Directory.Delete(LazyOperations.PatchFolder, true); - return $"Patching Complete. You can delete the patcher.exe file."; } } diff --git a/Patcher/PatcherUtils/PatcherUtils.csproj b/Patcher/PatcherUtils/PatcherUtils.csproj index 3ca61a5..08c5334 100644 --- a/Patcher/PatcherUtils/PatcherUtils.csproj +++ b/Patcher/PatcherUtils/PatcherUtils.csproj @@ -5,14 +5,10 @@ - - - - diff --git a/Patcher/PatcherUtils/Resources/PatchClient.exe b/Patcher/PatcherUtils/Resources/PatchClient.exe deleted file mode 100644 index 28b3544..0000000 --- a/Patcher/PatcherUtils/Resources/PatchClient.exe +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7d5d3b7f6b13f527516cdc3cf942d88822190a38953fe5f59f0a2fe617e2dc1d -size 90007902