Prevented overwriting of backups when reapplying mod

This commit is contained in:
Yoshi Askharoun
2021-05-30 23:48:48 -05:00
parent 3dbd9c58ed
commit 712a751bd7
4 changed files with 13 additions and 6 deletions
+4 -1
View File
@@ -1,6 +1,7 @@
using OwlCore.AbstractUI.Models; using OwlCore.AbstractUI.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Security.AccessControl; using System.Security.AccessControl;
using System.Security.Principal; using System.Security.Principal;
@@ -27,7 +28,9 @@ namespace ZuneModCore.Mods
#pragma warning disable CA1416 // Validate platform compatibility #pragma warning disable CA1416 // Validate platform compatibility
public override Task<string?> Apply() public override Task<string?> Apply()
{ {
// Make a backup of the file // Make a backup of the original file
FileVersionInfo wmvDllVersionInfo = FileVersionInfo.GetVersionInfo(WMVCORE_PATH);
if (Version.Parse(wmvDllVersionInfo.ProductVersion!) <= new Version(12, 0, 10586, 0))
File.Copy(WMVCORE_PATH, Path.Combine(StorageDirectory, "WMVCORE.original.dll"), true); File.Copy(WMVCORE_PATH, Path.Combine(StorageDirectory, "WMVCORE.original.dll"), true);
// Get the working WMVCORE.dll // Get the working WMVCORE.dll
+6 -2
View File
@@ -34,8 +34,12 @@ namespace ZuneModCore.Mods
return Task.FromResult<string?>($"The file '{zsDllInfo.FullName}' does not exist."); return Task.FromResult<string?>($"The file '{zsDllInfo.FullName}' does not exist.");
} }
// Make a backup of the file // Make a backup if it doesn't already exist
File.Copy(zsDllInfo.FullName, Path.Combine(StorageDirectory, "ZuneService.original.dll"), true); FileInfo zsDllBackupInfo = new(Path.Combine(StorageDirectory, "ZuneService.original.dll"));
if (zsDllBackupInfo.Exists)
{
File.Copy(zsDllInfo.FullName, zsDllBackupInfo.FullName, true);
}
try try
{ {
+1 -1
View File
@@ -8,7 +8,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" /> <PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="OwlCore" Version="0.0.2" /> <PackageReference Include="OwlCore" Version="0.0.6" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0" /> <PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
<PackageReference Include="TagLibSharp" Version="2.2.0" /> <PackageReference Include="TagLibSharp" Version="2.2.0" />
</ItemGroup> </ItemGroup>
+1 -1
View File
@@ -21,7 +21,7 @@
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="4.2.0" /> <PackageReference Include="Microsoft.AppCenter.Analytics" Version="4.2.0" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="4.2.0" /> <PackageReference Include="Microsoft.AppCenter.Crashes" Version="4.2.0" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" /> <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
<PackageReference Include="OwlCore" Version="0.0.2" /> <PackageReference Include="OwlCore" Version="0.0.6" />
</ItemGroup> </ItemGroup>
</Project> </Project>