diff options
Diffstat (limited to 'lib/tasks')
| -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 e49a84ecb..e50ee2cb8 100644 --- a/lib/tasks/temp.rake +++ b/lib/tasks/temp.rake @@ -40,6 +40,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}" | 
