From c8ee253ba67c03fbaeea37dfe29081ba4ced48a5 Mon Sep 17 00:00:00 2001 From: Greg Von Kuster Date: Sun, 27 Jan 2008 16:41:29 +0000 Subject: [PATCH] Missed committing similar fixes to cleanup_datasets script and admin controller. --- lib/galaxy/web/controllers/admin.py | 13 ++++++++++--- scripts/cleanup_datasets.py | 9 ++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/web/controllers/admin.py b/lib/galaxy/web/controllers/admin.py index 0e0da443f84..c0b5215a348 100644 --- a/lib/galaxy/web/controllers/admin.py +++ b/lib/galaxy/web/controllers/admin.py @@ -265,9 +265,16 @@ class Admin( BaseController ): for row in dt.select( dt.c.purged=='t' ).execute(): last = time.mktime( time.strptime( row.update_time.strftime( '%a %b %d %H:%M:%S %Y' ) ) ) diff = (now-last)/3600/24 # days - if diff > days: - data = self.app.model.Dataset.get( row.id ) - purged_file_name = data.file_name + "_purged" + if diff > days: + data = app.model.Dataset.get( row.id ) + # First try filename directly under file_path + purged_file_name = os.path.join( data.file_path, "dataset_%d.dat_purged" % data.id ) + # Only use that filename if it already exists (backward compatibility), + # otherwise construct hashed path + if not os.path.exists( purged_file_name ): + dir = os.path.join( data.file_path, *directory_hash_id( data.id ) ) + # Look for file inside hashed directory + purged_file_name = os.path.abspath( os.path.join( dir, "dataset_%d.dat_purged" % data.id ) ) if os.path.isfile( purged_file_name ): dataset_count += 1 try: diff --git a/scripts/cleanup_datasets.py b/scripts/cleanup_datasets.py index 103c66e135f..25e100e14ea 100644 --- a/scripts/cleanup_datasets.py +++ b/scripts/cleanup_datasets.py @@ -234,7 +234,14 @@ def info_remove_datasets( app, days ): diff = (now-last)/3600/24 # days if diff > days: data = app.model.Dataset.get( row.id ) - purged_file_name = data.file_name + "_purged" + # First try filename directly under file_path + purged_file_name = os.path.join( data.file_path, "dataset_%d.dat_purged" % data.id ) + # Only use that filename if it already exists (backward compatibility), + # otherwise construct hashed path + if not os.path.exists( purged_file_name ): + dir = os.path.join( data.file_path, *directory_hash_id( data.id ) ) + # Look for file inside hashed directory + purged_file_name = os.path.abspath( os.path.join( dir, "dataset_%d.dat_purged" % data.id ) ) if os.path.isfile( purged_file_name ): print "Dataset id %s with file_size %s will be removed from disk." %( str( row.id ), str( row.file_size ) ) dataset_count += 1