diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-08-16 17:35:58 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-08-16 17:35:58 +0100 |
commit | 6c8af1b86a8d0585118017ac44074ff33ca1a11f (patch) | |
tree | 60a49b73fd91e4cc17e46b4db1e37e26be4c47b7 | |
parent | 0703efa26d3de27f7d3a8ac26652068a632d13ca (diff) |
Also handle moved and deleted incoming messages.
-rw-r--r-- | lib/tasks/temp.rake | 20 |
1 files changed, 20 insertions, 0 deletions
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}" |