Skip to content

Commit

Permalink
Skip computing assets summary for invalid assets
Browse files Browse the repository at this point in the history
  • Loading branch information
danlamanna committed Feb 13, 2023
1 parent 1aefead commit 3b51b5d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions dandiapi/api/services/metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ def version_aggregate_assets_summary(version: Version):
if version.version != 'draft':
raise VersionHasBeenPublished()

version.metadata['assetsSummary'] = aggregate_assets_summary(
version.assets.values_list('metadata', flat=True).iterator()
)
try:
version.metadata['assetsSummary'] = aggregate_assets_summary(
version.assets.values_list('metadata', flat=True).iterator()
)
except Exception:
# The assets summary aggregation may fail if any asset metadata is invalid, skip
# updating it if it fails.
logger.info('Error calculating assetsSummary', exc_info=True)

Version.objects.filter(id=version.id, version='draft').update(
modified=timezone.now(), metadata=version.metadata
Expand Down

0 comments on commit 3b51b5d

Please sign in to comment.