Skip to content

Commit

Permalink
Update other quota manipulations to use the new user.adjust_quota_usa…
Browse files Browse the repository at this point in the history
…ge function.
  • Loading branch information
dannon committed Oct 13, 2015
1 parent 4cebca8 commit b77496e
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/galaxy/managers/hdas.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def purge( self, hda, flush=True):
super( HDAManager, self ).purge( hda, flush=flush )
# decrease the user's space used
if quota_amount_reduction:
user.total_disk_usage -= quota_amount_reduction
user.adjust_total_disk_usage(-quota_amount_reduction)
return hda

# .... states
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ def add_dataset( self, dataset, parent_id=None, genome_build=None, set_hid=True,
if set_hid:
dataset.hid = self._next_hid()
if quota and self.user:
self.user.total_disk_usage += dataset.quota_amount( self.user )
self.user.adjust_total_disk_usage(dataset.quota_amount(self.user))
dataset.history = self
if genome_build not in [None, '?']:
self.genome_build = genome_build
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/web/framework/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def handle_user_login( self, user ):
if prev_galaxy_session.user is None:
# Increase the user's disk usage by the amount of the previous history's datasets if they didn't already own it.
for hda in history.datasets:
user.total_disk_usage += hda.quota_amount( user )
user.adjust_total_disk_usage(hda.quota_amount( user ))
elif self.galaxy_session.current_history:
history = self.galaxy_session.current_history
if (not history and users_last_session and
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/galaxy/controllers/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ def _purge( self, trans, dataset_id ):
# HDA is purgeable
# Decrease disk usage first
if user:
user.total_disk_usage -= hda.quota_amount( user )
user.adjust_total_disk_usage(-hda.quota_amount(user))
# Mark purged
hda.purged = True
trans.sa_session.add( hda )
Expand Down
6 changes: 3 additions & 3 deletions lib/galaxy/webapps/galaxy/controllers/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def _list_delete( self, trans, histories, purge=False ):
if purge and trans.app.config.allow_user_dataset_purge:
for hda in history.datasets:
if trans.user:
trans.user.total_disk_usage -= hda.quota_amount( trans.user )
trans.user.adjust_total_disk_usage(-hda.quota_amount(trans.user))
hda.purged = True
trans.sa_session.add( hda )
trans.log_event( "HDA id %s has been purged" % hda.id )
Expand Down Expand Up @@ -1112,7 +1112,7 @@ def purge_deleted_datasets( self, trans ):
if not hda.deleted or hda.purged:
continue
if trans.user:
trans.user.total_disk_usage -= hda.quota_amount( trans.user )
trans.user.adjust_total_disk_usage(-hda.quota_amount(trans.user))
hda.purged = True
trans.sa_session.add( hda )
trans.log_event( "HDA id %s has been purged" % hda.id )
Expand Down Expand Up @@ -1142,7 +1142,7 @@ def delete_current( self, trans, purge=False ):
if purge and trans.app.config.allow_user_dataset_purge:
for hda in history.datasets:
if trans.user:
trans.user.total_disk_usage -= hda.quota_amount( trans.user )
trans.user.adjust_total_disk_usage(-hda.quota_amount(trans.user))
hda.purged = True
trans.sa_session.add( hda )
trans.log_event( "HDA id %s has been purged" % hda.id )
Expand Down
2 changes: 1 addition & 1 deletion scripts/cleanup_datasets/cleanup_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def _purge_dataset( app, dataset, remove_from_disk, info_only=False ):
if hda.history.user is not None and hda.history.user not in usage_users:
usage_users.append( hda.history.user )
for user in usage_users:
user.total_disk_usage -= dataset.get_total_size()
user.adjust_total_disk_usage(-dataset.get_total_size())
app.sa_session.add( user )
print "Purging dataset id", dataset.id
dataset.purged = True
Expand Down

0 comments on commit b77496e

Please sign in to comment.