Class: Colore::Sidekiq::LegacyPurgeWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker, Sidetiq::Schedulable
Defined in:
lib/sidekiq_workers.rb

Overview

This worker periodically purges legacy conversion files (the expectation is that apps using the legacy service will request the file shortly after posting the original, so won't need it after then).

Instance Method Summary collapse

Instance Method Details

#performObject

Looks for old legacy docs and deletes them


99
100
101
102
103
104
105
106
107
108
109
# File 'lib/sidekiq_workers.rb', line 99

def perform
  purge_seconds = (C_.legacy_purge_days || 1).to_f * 86400.0
  dir = LegacyConverter.new.legacy_dir
  dir.each_entry do |file|
    next if (dir+file).directory?
    if Time.now - (dir+file).ctime > purge_seconds
      (dir+file).unlink
      logger.debug "Deleted old legacy file: #{file}"
    end
  end
end