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

Abstraction for purging the dataset quota usage from a user. #10208

Merged
merged 1 commit into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3252,6 +3252,12 @@ def get_access_roles(self, trans):
"""
return self.dataset.get_access_roles(trans)

def purge_usage_from_quota(self, user):
"""Remove this HDA's quota_amount from user's quota.
"""
if user:
user.adjust_total_disk_usage(-self.quota_amount(user))

def quota_amount(self, user):
"""
Return the disk space used for this HDA relevant to user quotas.
Expand Down
3 changes: 1 addition & 2 deletions lib/galaxy/webapps/galaxy/controllers/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,7 @@ def _purge(self, trans, dataset_id):
hda.deleted = True
# HDA is purgeable
# Decrease disk usage first
if user:
user.adjust_total_disk_usage(-hda.quota_amount(user))
hda.purge_usage_from_quota(user)
# Mark purged
hda.purged = True
trans.sa_session.add(hda)
Expand Down
3 changes: 1 addition & 2 deletions lib/galaxy/webapps/galaxy/controllers/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,8 +1055,7 @@ def purge_deleted_datasets(self, trans):
for hda in trans.history.datasets:
if not hda.deleted or hda.purged:
continue
if trans.user:
trans.user.adjust_total_disk_usage(-hda.quota_amount(trans.user))
hda.purge_usage_from_quota(trans.user)
hda.purged = True
trans.sa_session.add(hda)
trans.log_event("HDA id %s has been purged" % hda.id)
Expand Down