Check for a DDS signature before attempting to analyze textures

This commit is contained in:
Timothy Baldridge 2021-07-17 17:03:22 -06:00
parent 9422b571b1
commit 631ccba553
7 changed files with 33 additions and 14 deletions

View File

@ -1,5 +1,8 @@
### Changelog ### Changelog
#### Version - 2.5.1.5 - 7/17/2021
* HOTFIX - Don't attempt to analyze files that have .dds extensions but are not DDS files internally
#### Version - 2.5.1.4 - 7/17/2021 #### Version - 2.5.1.4 - 7/17/2021
* Fix some broken VFS caching (that's existed for awhile) * Fix some broken VFS caching (that's existed for awhile)
* Enable perceptual hashing for files inside BSA file * Enable perceptual hashing for files inside BSA file

View File

@ -6,8 +6,8 @@
<AssemblyName>wabbajack-cli</AssemblyName> <AssemblyName>wabbajack-cli</AssemblyName>
<Company>Wabbajack</Company> <Company>Wabbajack</Company>
<Platforms>x64</Platforms> <Platforms>x64</Platforms>
<AssemblyVersion>2.5.1.4</AssemblyVersion> <AssemblyVersion>2.5.1.5</AssemblyVersion>
<FileVersion>2.5.1.4</FileVersion> <FileVersion>2.5.1.5</FileVersion>
<Copyright>Copyright © 2019-2021</Copyright> <Copyright>Copyright © 2019-2021</Copyright>
<Description>An automated ModList installer</Description> <Description>An automated ModList installer</Description>
<PublishReadyToRun>true</PublishReadyToRun> <PublishReadyToRun>true</PublishReadyToRun>

View File

@ -84,6 +84,8 @@ namespace Wabbajack.ImageHashing
} }
public static async Task<ImageState> GetState(AbsolutePath path) public static async Task<ImageState> GetState(AbsolutePath path)
{
try
{ {
var ph = new ProcessHelper var ph = new ProcessHelper
{ {
@ -113,5 +115,10 @@ namespace Wabbajack.ImageHashing
PerceptualHash = await GetPHash(path) PerceptualHash = await GetPHash(path)
}; };
} }
catch (Exception ex)
{
throw;
}
}
} }
} }

View File

@ -4,8 +4,8 @@
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework> <TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
<AssemblyVersion>2.5.1.4</AssemblyVersion> <AssemblyVersion>2.5.1.5</AssemblyVersion>
<FileVersion>2.5.1.4</FileVersion> <FileVersion>2.5.1.5</FileVersion>
<Copyright>Copyright © 2019-2020</Copyright> <Copyright>Copyright © 2019-2020</Copyright>
<Description>Wabbajack Application Launcher</Description> <Description>Wabbajack Application Launcher</Description>
<PublishReadyToRun>true</PublishReadyToRun> <PublishReadyToRun>true</PublishReadyToRun>

View File

@ -3,8 +3,8 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework> <TargetFramework>net5.0-windows</TargetFramework>
<AssemblyVersion>2.5.1.4</AssemblyVersion> <AssemblyVersion>2.5.1.5</AssemblyVersion>
<FileVersion>2.5.1.4</FileVersion> <FileVersion>2.5.1.5</FileVersion>
<Copyright>Copyright © 2019-2021</Copyright> <Copyright>Copyright © 2019-2021</Copyright>
<Description>Wabbajack Server</Description> <Description>Wabbajack Server</Description>
<RuntimeIdentifier>win-x64</RuntimeIdentifier> <RuntimeIdentifier>win-x64</RuntimeIdentifier>

View File

@ -7,6 +7,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Compression.BSA;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams; using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
using K4os.Hash.Crc; using K4os.Hash.Crc;
using Wabbajack.Common; using Wabbajack.Common;
@ -190,7 +191,7 @@ namespace Wabbajack.VirtualFileSystem
}; };
} }
private static SignatureChecker DDSSig = new(Definitions.FileType.DSS);
public static async Task<VirtualFile> Analyze(Context context, VirtualFile parent, IStreamFactory extractedFile, public static async Task<VirtualFile> Analyze(Context context, VirtualFile parent, IStreamFactory extractedFile,
IPath relPath, int depth = 0) IPath relPath, int depth = 0)
{ {
@ -226,11 +227,19 @@ namespace Wabbajack.VirtualFileSystem
Hash = hash, Hash = hash,
}; };
if (Consts.TextureExtensions.Contains(relPath.FileName.Extension)) if (Consts.TextureExtensions.Contains(relPath.FileName.Extension) && (await DDSSig.MatchesAsync(stream)) != null)
{
try
{ {
self.ImageState = await ImageState.FromImageStream(stream, relPath.FileName.Extension, false); self.ImageState = await ImageState.FromImageStream(stream, relPath.FileName.Extension, false);
stream.Position = 0; stream.Position = 0;
} }
catch (Exception)
{
Utils.Log($"Unable to perform perceptual hashing on {relPath.FileName} in {parent.FullPath}");
throw;
}
}
self.FillFullPath(depth); self.FillFullPath(depth);

View File

@ -6,8 +6,8 @@
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
<Platforms>x64</Platforms> <Platforms>x64</Platforms>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier> <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<AssemblyVersion>2.5.1.4</AssemblyVersion> <AssemblyVersion>2.5.1.5</AssemblyVersion>
<FileVersion>2.5.1.4</FileVersion> <FileVersion>2.5.1.5</FileVersion>
<Copyright>Copyright © 2019-2021</Copyright> <Copyright>Copyright © 2019-2021</Copyright>
<Description>An automated ModList installer</Description> <Description>An automated ModList installer</Description>
<PublishReadyToRun>true</PublishReadyToRun> <PublishReadyToRun>true</PublishReadyToRun>