Skip to content

Commit 3fcc2ab

Browse files
committed
Prevent dandiset deletion if doi delete fails
1 parent 6102d45 commit 3fcc2ab

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

dandiapi/api/services/dandiset/__init__.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,19 @@ def delete_dandiset(*, user, dandiset: Dandiset) -> None:
7878
if dandiset.unembargo_in_progress:
7979
raise DandisetUnembargoInProgressError
8080

81-
# Check if there's a DOI that needs to be handled
82-
draft_version = dandiset.versions.filter(version='draft').first()
83-
8481
# Delete all versions first, so that AssetPath deletion is cascaded
8582
# through versions, rather than through zarrs directly
8683
with transaction.atomic():
8784
# Record the audit event first so that the AuditRecord instance has a
8885
# chance to grab the Dandiset information before it is destroyed.
8986
audit.delete_dandiset(dandiset=dandiset, user=user)
87+
9088
# Dandisets with published versions cannot be deleted
91-
# so only the Dandiset DOI needs to be delete.
89+
# so only the Dandiset DOI needs to be deleted.
90+
draft_version = dandiset.versions.filter(version='draft').first()
9291
if draft_version and draft_version.doi is not None:
93-
try:
94-
doi.delete_or_hide_doi(draft_version.doi)
95-
except Exception:
96-
pass # doi operation should not stop deletion. delete_or_hide will log the exception.
92+
# Call DOI deletion prior to delete so if this raises, we do not proceed
93+
doi.delete_or_hide_doi(draft_version.doi)
9794
dandiset.versions.all().delete()
9895
dandiset.delete()
9996

0 commit comments

Comments
 (0)