diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 1611718175dc..25ca0f8f6086 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -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. diff --git a/lib/galaxy/webapps/galaxy/controllers/dataset.py b/lib/galaxy/webapps/galaxy/controllers/dataset.py index ddff58252baa..c8ddc603cf2e 100644 --- a/lib/galaxy/webapps/galaxy/controllers/dataset.py +++ b/lib/galaxy/webapps/galaxy/controllers/dataset.py @@ -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) diff --git a/lib/galaxy/webapps/galaxy/controllers/history.py b/lib/galaxy/webapps/galaxy/controllers/history.py index cdd11c847e10..7c551660f9ee 100644 --- a/lib/galaxy/webapps/galaxy/controllers/history.py +++ b/lib/galaxy/webapps/galaxy/controllers/history.py @@ -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)