Improve the CLI verification routines

This commit is contained in:
Halgari 2022-10-24 17:28:03 -06:00
parent 2b943c0da3
commit 0bd79a40cd
5 changed files with 28 additions and 9 deletions

View File

@ -70,7 +70,7 @@ public class ModlistReport
string FixupTo(RelativePath path)
{
if (path.GetPart(0) != StandardInstaller.BSACreationDir.ToString()) return path.ToString();
if (path.GetPart(0) != Consts.BSACreationDir.ToString()) return path.ToString();
var bsaId = path.GetPart(1);
if (!bsas.TryGetValue(bsaId, out var bsa))

View File

@ -42,10 +42,28 @@ public class VerifyModlistInstall
_logger.LogInformation("Scanning files");
foreach (var directive in list.Directives)
{
if (directive is ArchiveMeta)
continue;
if (directive is RemappedInlineFile)
continue;
if (directive.To.InFolder(Consts.BSACreationDir))
continue;
var dest = directive.To.RelativeTo(installFolder);
if (!dest.FileExists())
{
errors.Add(new Result
{
Path = directive.To,
Message = $"File does not exist directive {directive.GetType()}"
});
continue;
}
if (dest.Size() != directive.Size)
{
errors.Add(new Result()
errors.Add(new Result
{
Path = directive.To,
Message = $"Sizes do not match got {dest.Size()} expected {directive.Size}"

View File

@ -41,7 +41,7 @@ public abstract class AInstaller<T>
where T : AInstaller<T>
{
private const int _limitMS = 100;
public static RelativePath BSACreationDir = "TEMP_BSA_FILES".ToRelativePath();
private static readonly Regex NoDeleteRegex = new(@"(?i)[\\\/]\[NoDelete\]", RegexOptions.Compiled);
protected readonly InstallerConfiguration _configuration;
@ -498,8 +498,8 @@ public abstract class AInstaller<T>
return d switch
{
CreateBSA bsa => !bsasToNotBuild.Contains(bsa.TempID),
FromArchive a when a.To.StartsWith($"{BSACreationDir}") => !bsasToNotBuild.Any(b =>
a.To.RelativeTo(_configuration.Install).InFolder(_configuration.Install.Combine(BSACreationDir, b))),
FromArchive a when a.To.StartsWith($"{Consts.BSACreationDir}") => !bsasToNotBuild.Any(b =>
a.To.RelativeTo(_configuration.Install).InFolder(_configuration.Install.Combine(Consts.BSACreationDir, b))),
_ => true
};
}).ToDictionary(d => d.To);

View File

@ -26,4 +26,5 @@ public static class Consts
public const string StepDownloading = "Downloading";
public const string StepHashing = "Hashing";
public const string StepFinished = "Finished";
public static RelativePath BSACreationDir = "TEMP_BSA_FILES".ToRelativePath();
}

View File

@ -282,7 +282,7 @@ public class StandardInstaller : AInstaller<StandardInstaller>
{
UpdateProgress(1);
_logger.LogInformation("Building {bsaTo}", bsa.To.FileName);
var sourceDir = _configuration.Install.Combine(BSACreationDir, bsa.TempID);
var sourceDir = _configuration.Install.Combine(Consts.BSACreationDir, bsa.TempID);
await using var a = BSADispatch.CreateBuilder(bsa.State, _manager);
var streams = await bsa.FileStates.PMapAllBatchedAsync(_limiter, async state =>
@ -314,7 +314,7 @@ public class StandardInstaller : AInstaller<StandardInstaller>
var hash = await stream.Hash(token);
var astate = bsa.FileStates.First(f => f.Path == state.Path);
var srcDirective = indexedByDestination[BSACreationDir.Combine(bsa.TempID, astate.Path)];
var srcDirective = indexedByDestination[Consts.BSACreationDir.Combine(bsa.TempID, astate.Path)];
//DX10Files are lossy
if (astate is not BA2DX10File)
ThrowOnNonMatchingHash(bsa, srcDirective, astate, hash);
@ -322,10 +322,10 @@ public class StandardInstaller : AInstaller<StandardInstaller>
}).ToHashSet();
}
var bsaDir = _configuration.Install.Combine(BSACreationDir);
var bsaDir = _configuration.Install.Combine(Consts.BSACreationDir);
if (bsaDir.DirectoryExists())
{
_logger.LogInformation("Removing temp folder {bsaCreationDir}", BSACreationDir);
_logger.LogInformation("Removing temp folder {bsaCreationDir}", Consts.BSACreationDir);
bsaDir.DeleteDirectory();
}
}