Skip to content

Commit

Permalink
Improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgamerz committed Jan 30, 2021
1 parent b6756f8 commit 1c66f7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ALOTInstallerCore/Steps/InstallStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void InstallTextures(object sender, DoWorkEventArgs doWorkEventArgs)
Log.Information(@"[AICORE] Beginning InstallTextures() thread.");
#region Presetup variables
var filesThatWillInstall = Directory.GetFiles(memInputPath, "*.mem");
var mainInstallStageWillCommence = Enumerable.Any(filesThatWillInstall);
var mainInstallStageWillCommence = filesThatWillInstall.Any();
Log.Information($@"[AICORE] Main texture installation step (+ supporting steps) will commence: {mainInstallStageWillCommence}");

#endregion
Expand Down Expand Up @@ -350,7 +350,7 @@ string getMeuitmIDStr(InstallerFile meuitmF)
Log.Information("[AICORE] The following files are going to be installed:");
foreach (var f in filesThatWillInstall)
{
Log.Information(Path.GetFileName(f));
Log.Information($@"[AICORE] {Path.GetFileName(f)}");
}

SetMiddleTextCallback?.Invoke("Setting up texture installer");
Expand Down
14 changes: 11 additions & 3 deletions ALOTInstallerCore/Steps/StageStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void handleIPC(string command, string param)
// If any package files list TPFSource disable this space optimization
if (extensions.Count == 1 && instFile.PackageFiles.Where(x => x.ApplicableGames.HasFlag(targetGame)).All(x => x.TPFSource == null))
{

// We have only one extension type! We can filter what we extract with MEM
args += $" --filter-with-ext {extensions.First().Substring(1)}"; //remove the '.'
}
Expand Down Expand Up @@ -274,7 +274,7 @@ public void PerformStaging(object sender, DoWorkEventArgs e)
#if DEBUG
//if (!v.FriendlyName.Contains("ALOT"))
//{
block.Post(v);
block.Post(v);
//}
#else
// Helps make sure I don't publish broken code
Expand Down Expand Up @@ -396,6 +396,8 @@ private void sortInstallerFileSet(InstallOptionsPackage installOptions, ref int
{
// There was an error
//UpdateStatusCallback?.Invoke($"Error extracting {installerFile.FriendlyName}, checking file");
Log.Error($@"[AICORE] [{prefix}] Error extracting archive, checksumming...");

installerFile.StatusText = "Error extracting, checking archive";
using var sourcefStream = File.OpenRead(installerFile.GetUsedFilepath());
long sizeToHash = sourcefStream.Length;
Expand All @@ -409,15 +411,18 @@ private void sortInstallerFileSet(InstallOptionsPackage installOptions, ref int
}).Result;
if (hash == mf.GetBackingHash())
{
Log.Error($@"[AICORE] [{prefix}] Error extracting archive, however checksum matches manifest - possible disk issues...?");
ErrorStagingCallback?.Invoke($"Error extracting {installerFile.GetUsedFilepath()}, but file matches manifest - possible disk issues?");
}
else
{
Log.Error($@"[AICORE] [{prefix}] Error extracting archive, checksums don't match expected values, file is corrupt");
ErrorStagingCallback?.Invoke($"File is corrupt: {installerFile.GetUsedFilepath()}, this file should be deleted and redownloaded.\nExpected hash:{mf.GetBackingHash()}\nHash of file: {hash}");
}
}
else
{
Log.Error($@"[AICORE] [{prefix}] Error extracting archive, size is zero bytes");
ErrorStagingCallback?.Invoke($"Unable to read {installerFile.GetUsedFilepath()}, size is 0 bytes");
}
_abortStaging = true;
Expand Down Expand Up @@ -585,6 +590,9 @@ private void sortInstallerFileSet(InstallOptionsPackage installOptions, ref int
}
}
}
} else
{
Log.Warning($@"[AICORE] [{prefix}] Fell through archiveextracted() (TEST MESSAGE)");
}

// Single file unpacked
Expand Down Expand Up @@ -933,7 +941,7 @@ private List<InstallerFile> resolveMutualExclusiveGroups()
if (pair.Value.Count > 1)
{
// Has issue
var chosenFile = ResolveMutualExclusiveMods?.Invoke(pair.Value.OfType<ManifestFile>().OrderByDescending(x=>x.Recommendation).OfType<InstallerFile>().ToList());
var chosenFile = ResolveMutualExclusiveMods?.Invoke(pair.Value.OfType<ManifestFile>().OrderByDescending(x => x.Recommendation).OfType<InstallerFile>().ToList());
if (chosenFile == null) return null;//abort
files.Insert(0, chosenFile);
}
Expand Down

0 comments on commit 1c66f7c

Please sign in to comment.