Skip to content

Commit

Permalink
Fix purging datasets whose total_size is None.
Browse files Browse the repository at this point in the history
Fix the error:

Removing disk, file  /opt/galaxy/database/files/000/dataset_192.dat
Error attempting to purge data file:  /opt/galaxy/database/files/000/dataset_192.dat  error:  unsupported operand type(s) for -=: 'Decimal' and 'NoneType'

when running:

python scripts/cleanup_datasets/cleanup_datasets.py config/galaxy.ini -d 10 -3 -r
  • Loading branch information
nsoranzo committed Aug 19, 2015
1 parent f01300d commit 238d908
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1434,13 +1434,11 @@ def set_size( self ):
def get_total_size( self ):
if self.total_size is not None:
return self.total_size
if self.file_size:
# for backwards compatibility, set if unset
self.set_total_size()
db_session = object_session( self )
db_session.flush()
return self.total_size
return 0
# for backwards compatibility, set if unset
self.set_total_size()
db_session = object_session( self )
db_session.flush()
return self.total_size
def set_total_size( self ):
if self.file_size is None:
self.set_size()
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 @@ -465,7 +465,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.total_size
user.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 238d908

Please sign in to comment.