in src/managed/DiffGen/ArchiveUtility/ArchiveLoader.cs [43:100]
public static bool TryLoadArchive(ArchiveLoaderContext context, out ArchiveTokenization tokens, IArchive archive)
{
var type = archive.GetType();
context.Logger?.Log(context.LogLevel, "Testing if archive is format: {0}", type.FullName);
if (context.TokenCache.ContainsKey(type))
{
tokens = context.TokenCache[type];
context.Logger?.Log(context.LogLevel, "Found previously loaded tokens for type: {0}. ArchiveItem: {1}", type.FullName, tokens.ArchiveItem.GetSha256HashString());
return true;
}
if (!archive.IsMatchingFormat())
{
context.Logger?.Log(context.LogLevel, "Archive is not of format: {0}", type.FullName);
tokens = null;
return false;
}
else
{
context.Logger?.Log(context.LogLevel, "Archive is of format: {0}", type.FullName);
}
// We may have already gotten tokens from determing if this was the same type
if (context.TokenCache.ContainsKey(type))
{
tokens = context.TokenCache[type];
return true;
}
if (context.CancellationToken != CancellationToken.None)
{
context.CancellationToken.ThrowIfCancellationRequested();
}
try
{
tokens = archive.Tokenize();
context.TokenCache[type] = tokens;
context.Logger?.Log(context.LogLevel, "Setting into Token Cache: ArchiveItem: {0}", tokens.ArchiveItem.GetSha256HashString());
return true;
}
catch (FatalException)
{
throw;
}
catch (Exception e)
{
context.Logger?.LogError("Exception occurred while processing format: {0}", type.FullName);
context.Logger?.LogError("Exception: {0}", e.ToString());
tokens = null;
return false;
}
}