Sha256: e22650c63825c35babe6d57bfdd66a3a19f86cd419f42674f24805fa78ae9f15

Contents?: true

Size: 1.05 KB

Versions: 14

Compression:

Stored size: 1.05 KB

Contents

require 'kaya'

module Kaya
  module Workers
    class GarbageCleaner

      # This worker delete all zombies files
      include Sidekiq::Worker
        def perform

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

          get_present_output_files = Dir["#{Dir.pwd}/kaya/temp/*.out"].select{|file|  file.start_with? "kaya_co_"}
          get_present_report_files = Dir["#{Dir.pwd}/kaya/temp/*.html"].select{|file|  file.start_with? "kaya_report_"}

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

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
kaya-0.0.14 lib/kaya/background_jobs/workers/garbage_cleaner.rb
kaya-0.0.13 lib/kaya/background_jobs/workers/garbage_cleaner.rb
kaya-0.0.12 lib/kaya/background_jobs/workers/garbage_cleaner.rb
kaya-0.0.11 lib/kaya/background_jobs/workers/garbage_cleaner.rb
kaya-0.0.10 lib/kaya/background_jobs/workers/garbage_cleaner.rb
kaya-0.0.9 lib/kaya/background_jobs/workers/garbage_cleaner.rb
kaya-0.0.8 lib/kaya/background_jobs/workers/garbage_cleaner.rb
kaya-0.0.7 lib/kaya/background_jobs/workers/garbage_cleaner.rb
kaya-0.0.6 lib/kaya/background_jobs/workers/garbage_cleaner.rb
kaya-0.0.5 lib/kaya/background_jobs/workers/garbage_cleaner.rb
kaya-0.0.4 lib/kaya/background_jobs/workers/garbage_cleaner.rb
kaya-0.0.3 lib/kaya/background_jobs/workers/garbage_cleaner.rb
kaya-0.0.2 lib/kaya/background_jobs/workers/garbage_cleaner.rb
kaya-0.0.1 lib/kaya/background_jobs/workers/garbage_cleaner.rb