diff --git a/src/Stars.Data/Model/Metadata/Bka/BkaMetadataExtractor.cs b/src/Stars.Data/Model/Metadata/Bka/BkaMetadataExtractor.cs index e779c142..9ad23ac0 100644 --- a/src/Stars.Data/Model/Metadata/Bka/BkaMetadataExtractor.cs +++ b/src/Stars.Data/Model/Metadata/Bka/BkaMetadataExtractor.cs @@ -80,7 +80,7 @@ protected override async Task ExtractMetadata(IItem item, string suffi var tmpDestination = LocalFileDestination.Create(_fileSystem.Directory.CreateDirectory(Path.GetDirectoryName(topZipArchiveAsset.Uri.AbsolutePath)), item, true); IAssetsContainer topZipAssets = await topZipArchiveAsset.ExtractToDestinationAsync(tmpDestination, _carrierManager, System.Threading.CancellationToken.None); - IAsset productZipAsset = GetProductZipAsset(topZipAssets); + IAsset productZipAsset = GetProductZipAsset(topZipAsset, topZipAssets); if (productZipAsset != null) { ZipArchiveAsset productZipArchiveAsset = new ZipArchiveAsset(productZipAsset, logger, resourceServiceProvider, _fileSystem); @@ -106,6 +106,11 @@ protected override async Task ExtractMetadata(IItem item, string suffi IAsset[] metadataAssets = GetMetadataAssets(item, innerZipAssetContainers); + if (metadataAssets == null) + { + throw new Exception("No metadata assets found"); + } + BkaMetadata[] metadata = await ReadMetadata(metadataAssets); StacItem stacItem = CreateStacItem(metadata); @@ -544,8 +549,13 @@ protected virtual IAsset GetTopZipAsset(IItem item) return zipAsset; } - protected virtual IAsset GetProductZipAsset(IAssetsContainer container) + protected virtual IAsset GetProductZipAsset(IAsset topAsset, IAssetsContainer container) { + if (topAsset.Uri.AbsolutePath.EndsWith("PRODUCT.zip")) + { + return topAsset; + } + IAsset zipAsset = FindFirstAssetFromFileNameRegex(container, @"PRODUCT\.zip"); return zipAsset; }