From 6c8af1b86a8d0585118017ac44074ff33ca1a11f Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 16 Aug 2012 17:35:58 +0100 Subject: Also handle moved and deleted incoming messages. --- lib/tasks/temp.rake | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib/tasks/temp.rake') diff --git a/lib/tasks/temp.rake b/lib/tasks/temp.rake index 9decc13db..669cdf989 100644 --- a/lib/tasks/temp.rake +++ b/lib/tasks/temp.rake @@ -31,6 +31,26 @@ namespace :temp do if ! dryrun FileUtils.rm_rf(request_subdir) end + else + Dir.glob(File.join(request_subdir, 'response', '*')) do |response_subdir| + incoming_message_id = File.basename(response_subdir) + puts "Looking for IncomingMessage with id #{incoming_message_id}" if verbose + begin + incoming_message = IncomingMessage.find(incoming_message_id) + puts "Got IncomingMessage #{incoming_message_id}" if verbose + if incoming_message.info_request != info_request + puts "Deleting cache at #{response_subdir}: IncomingMessage #{incoming_message_id} has been moved from InfoRequest #{info_request_id}" + if ! dryrun + FileUtils.rm_rf(response_subdir) + end + end + rescue ActiveRecord::RecordNotFound + puts "Deleting cache at #{response_subdir} for deleted IncomingMessage #{incoming_message_id}" + if ! dryrun + FileUtils.rm_rf(response_subdir) + end + end + end end rescue ActiveRecord::RecordNotFound puts "Deleting cache at #{request_subdir} for deleted InfoRequest #{info_request_id}" -- cgit v1.2.3