Class: Mutx::Workers::GarbageCleaner

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
lib/mutx/background_jobs/workers/garbage_cleaner.rb

Instance Method Summary collapse

Instance Method Details

#performObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mutx/background_jobs/workers/garbage_cleaner.rb', line 10

def perform

  Mutx::Support::Configuration.get
  Mutx::Database::MongoConnector.new(Mutx::Support::Configuration.db_connection_data)

  get_present_output_files = Dir["#{Dir.pwd}/mutx/temp/*.out"].select{|file|  file.start_with? "mutx_co_"}
  get_present_report_files = Dir["#{Dir.pwd}/mutx/temp/*.html"].select{|file|  file.start_with? "mutx_report_"}

  get_present_output_files.each do |output_file|
    if result = Mutx::Results::Result.get(output_file.scan(/\d+/).first)
      File.delete("#{Dir.pwd}/mutx/temp/#{output_file}") if result.finished?
    end
  end

  get_present_report_files.each do |report_file|
    if result = Mutx::Results::Result.get(report_file.scan(/\d+/).first)
      File.delete("#{Dir.pwd}/mutx/temp/#{report_file}") if result.finished?
    end
  end
end