Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

files: handle disabled state on deleting draft #260

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions invenio_drafts_resources/services/records/components/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,12 @@ def new_version(self, identity, draft=None, record=None):

def _purge_bucket_and_ovs(self, files):
"""Purge associated bucket and object versions."""
if files.bucket.locked:
files.unlock()
if files.enabled:
files.delete_all(softdelete_obj=False, remove_rf=True)
files.remove_bucket(force=True)
if files.bucket:
if files.bucket.locked:
files.unlock()
if files.enabled:
files.delete_all(softdelete_obj=False, remove_rf=True)
files.remove_bucket(force=True)

def _publish_new(self, identity, draft, record):
"""Action when publishing a new draft."""
Expand Down Expand Up @@ -275,7 +276,7 @@ def delete_draft(self, identity, draft=None, record=None, force=False):
"""
draft_files = self.get_record_files(draft)

# Teardown the bucket and files.
# Teardown the bucket and files if any.
self._purge_bucket_and_ovs(draft_files)

def import_files(self, identity, draft=None, record=None):
Expand Down
Loading