Make GetFileStream safer until fixed

This commit is contained in:
Matt Nadareski
2024-07-15 21:44:05 -04:00
parent 0e97b2025a
commit 5dc6b658d2

View File

@@ -743,13 +743,22 @@ namespace SabreTools.DatTools
if (isZip != null)
{
BaseArchive? archive = BaseArchive.Create(file);
if (archive != null)
if (archive == null)
return false;
try
{
// TODO: Write entry to a temporary file to avoid over-large in-memory streams
// TODO: Once entry is written, replace GetEntryStream implementations
ItemType itemType = datItem.GetStringFieldValue(Models.Metadata.DatItem.TypeKey).AsEnumValue<ItemType>();
(stream, _) = archive.GetEntryStream(datItem.GetName() ?? itemType.AsStringValue() ?? string.Empty);
}
catch
{
// Ignore the exception for now -- usually an over-large file
stream = null;
return false;
}
}
// Otherwise, just open the filestream
else