Can install compile install verify TPF!

This commit is contained in:
Timothy Baldridge 2022-05-31 17:14:27 -06:00
parent 72be066bbf
commit c7908fe08e
5 changed files with 36 additions and 8 deletions

View File

@ -17,6 +17,8 @@ public class CompilerSettings
public AbsolutePath ModListImage { get; set; }
public bool UseGamePaths { get; set; }
public bool UseTextureRecompression { get; set; } = false;
public Game[] OtherGames { get; set; } = Array.Empty<Game>();
public TimeSpan MaxVerificationTime { get; set; } = TimeSpan.FromMinutes(1);

View File

@ -27,7 +27,7 @@ public class CompilerSettingsInferencer
public async Task<CompilerSettings?> InferFromRootPath(AbsolutePath rootPath)
{
var mo2File = rootPath.Combine(Consts.MO2IniName).LoadIniFile();
var profile = mo2File["General"]["selected_profile"];
var profile = mo2File["General"]["selected_profile"].FromMO2Ini();
return await InferModListFromLocation(rootPath.Combine(Consts.MO2Profiles, profile, Consts.ModListTxt));
}
@ -88,6 +88,10 @@ public class CompilerSettingsInferencer
if ((generalModData["notes"]?.Contains(Consts.WABBAJACK_NOMATCH_INCLUDE) ?? false) ||
(generalModData["comments"]?.Contains(Consts.WABBAJACK_NOMATCH_INCLUDE) ?? false))
cs.NoMatchInclude = cs.NoMatchInclude.Append(modFolder.RelativeTo(mo2Folder)).ToArray();
if ((generalModData["notes"]?.Contains(Consts.WABBAJACK_INCLUDE) ?? false) ||
(generalModData["comments"]?.Contains(Consts.WABBAJACK_INCLUDE) ?? false))
cs.Include = cs.Include.Append(modFolder.RelativeTo(mo2Folder)).ToArray();
}
_logger.LogInformation("Finding other profiles");

View File

@ -313,8 +313,8 @@ public class MO2Compiler : ACompiler
new DropAll(this)
};
//if (DisableTextureResizing)
// steps = steps.Where(s => !(s is MatchSimilarTextures)).ToList();
if (!_settings.UseTextureRecompression)
steps = steps.Where(s => s is not MatchSimilarTextures).ToList();
return steps;
}

View File

@ -251,6 +251,7 @@ public abstract class AInstaller<T>
await using var s = await sf.GetStream();
await using var of = directive.Directive.To.RelativeTo(_configuration.Install)
.Open(FileMode.Create, FileAccess.Write);
_logger.LogInformation("Recompressing {Filename}", tt.To.FileName);
await ImageLoader.Recompress(s, tt.ImageState.Width, tt.ImageState.Height, tt.ImageState.Format,
of, token);
}

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.AccessControl;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@ -22,9 +23,27 @@ public static class AbsolutePathExtensions
{
var path = file.ToNativePath();
if (File.Exists(path))
File.Delete(path);
{
try
{
File.Delete(path);
}
catch (UnauthorizedAccessException ex)
{
var fi = new FileInfo(path);
if (fi.IsReadOnly)
{
fi.IsReadOnly = false;
File.Delete(path);
}
else
{
throw;
}
}
}
if (Directory.Exists(path))
Directory.Delete(path, true);
file.DeleteDirectory();
}
public static long Size(this AbsolutePath file)
@ -188,17 +207,19 @@ public static class AbsolutePathExtensions
if (!path.DirectoryExists()) return;
if (dontDeleteIfNotEmpty && (path.EnumerateFiles().Any() || path.EnumerateDirectories().Any())) return;
foreach (string directory in Directory.GetDirectories(path.ToString()))
foreach (var directory in Directory.GetDirectories(path.ToString()))
{
DeleteDirectory(directory.ToAbsolutePath(), dontDeleteIfNotEmpty);
}
try
{
Directory.Delete(path.ToString(), true);
}
catch (IOException)
{
var di = new DirectoryInfo(path.ToString());
if (di.Attributes.HasFlag(FileAttributes.ReadOnly))
di.Attributes &= ~FileAttributes.ReadOnly;
Directory.Delete(path.ToString(), true);
}
catch (UnauthorizedAccessException)