Fix case sensitive bug with download deletion during install

This commit is contained in:
Timothy Baldridge 2019-12-12 15:52:24 -07:00
parent 45a08b4005
commit e482197479
4 changed files with 35 additions and 3 deletions

View File

@ -928,5 +928,12 @@ namespace Wabbajack.Common
var decoded = ProtectedData.Unprotect(bytes, Encoding.UTF8.GetBytes(key), DataProtectionScope.LocalMachine);
return Encoding.UTF8.GetString(decoded).FromJSONString<T>();
}
public static bool IsInPath(this string path, string parent)
{
return path.ToLower().TrimEnd('\\').StartsWith(parent.ToLower().TrimEnd('\\') + "\\");
}
}
}

View File

@ -348,10 +348,8 @@ namespace Wabbajack.Lib
{
var relative_to = f.RelativeTo(OutputFolder);
Utils.Status($"Checking if modlist file {relative_to}");
if (indexed.ContainsKey(relative_to) || f.StartsWith(DownloadFolder + Path.DirectorySeparator))
{
if (indexed.ContainsKey(relative_to) || f.IsInPath(DownloadFolder))
return;
}
Utils.Log($"Deleting {relative_to} it's not part of this modlist");
File.Delete(f);

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wabbajack.Common;
namespace Wabbajack.Test
{
[TestClass]
public class UtilsTests
{
[TestMethod]
public void IsInPathTests()
{
Assert.IsTrue("c:\\foo\\bar.exe".IsInPath("c:\\foo"));
Assert.IsFalse("c:\\foo\\bar.exe".IsInPath("c:\\fo"));
Assert.IsTrue("c:\\Foo\\bar.exe".IsInPath("c:\\foo"));
Assert.IsTrue("c:\\foo\\bar.exe".IsInPath("c:\\Foo"));
Assert.IsTrue("c:\\foo\\bar.exe".IsInPath("c:\\fOo"));
Assert.IsTrue("c:\\foo\\bar.exe".IsInPath("c:\\foo\\"));
Assert.IsTrue("c:\\foo\\bar\\".IsInPath("c:\\foo\\"));
}
}
}

View File

@ -112,6 +112,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ContentRightsManagementTests.cs" />
<Compile Include="CompilationStackTests.cs" />
<Compile Include="UtilsTests.cs" />
<Compile Include="VortexTests.cs" />
<Compile Include="WebAutomationTests.cs" />
<Compile Include="zEditIntegrationTests.cs" />