From daae1876c39f361bbfd1ea3cd0a5c394196df294 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Sat, 27 Jun 2015 10:28:28 -0400 Subject: [PATCH] Fix managers to pass context necessary down the chain when purging. This should fix at least one quota calc error. Fix another bug in hda manager regarding quota reduction -- quota usage must be calculated prior to actually purging, otherwise the disk usage is 0 and this does nothing. Slight refactoring in manager purge -- we don't need to pass the user via context since we can just grab it where applicable from the history. Fix purge when handling an anonymous user --- lib/galaxy/managers/hdas.py | 10 +++++++--- lib/galaxy/managers/histories.py | 1 - 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/managers/hdas.py b/lib/galaxy/managers/hdas.py index e724d660a59..18e9955e906 100644 --- a/lib/galaxy/managers/hdas.py +++ b/lib/galaxy/managers/hdas.py @@ -143,14 +143,18 @@ class HDAManager( datasets.DatasetAssociationManager, return ldda.to_history_dataset_association( history, add_to_history=True ) # .... deletion and purging - def purge( self, hda, current_user=None, flush=True ): + def purge( self, hda, flush=True): """ Purge this HDA and the dataset underlying it. """ + user = hda.history.user or None + quota_amount_reduction = 0 + if user: + quota_amount_reduction = hda.quota_amount( user ) super( HDAManager, self ).purge( hda, flush=flush ) # decrease the user's space used - if current_user: - current_user.total_disk_usage -= hda.quota_amount( current_user ) + if quota_amount_reduction: + user.total_disk_usage -= quota_amount_reduction return hda # .... states diff --git a/lib/galaxy/managers/histories.py b/lib/galaxy/managers/histories.py index 14e53aa230d..1ebe9269bdb 100644 --- a/lib/galaxy/managers/histories.py +++ b/lib/galaxy/managers/histories.py @@ -82,7 +82,6 @@ class HistoryManager( sharable.SharableModelManager, deletable.PurgableManagerMi Purge this history and all HDAs, Collections, and Datasets inside this history. """ self.hda_manager.dataset_manager.error_unless_dataset_purge_allowed() - # First purge all the datasets for hda in history.datasets: if not hda.purged: