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
This commit is contained in:
Dannon Baker
2015-06-30 08:41:52 -04:00
parent 9059c4c96e
commit daae1876c3
2 changed files with 7 additions and 4 deletions
+7 -3
View File
@@ -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
-1
View File
@@ -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: