Method: CloudTempfile::Storage#delete_expired_tempfiles
- Defined in:
- lib/cloud_tempfile/storage.rb
#delete_expired_tempfiles ⇒ Object
Delete the expired file which are expired if the “config.clean_up” is true and “config.clean_up_older_than” is the amount of seconds it is older than.
Note: This action should be used with the “bundle exec rake cloud_temp_file:clear” rake command (cronjob)
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/cloud_tempfile/storage.rb', line 73 def delete_expired_tempfiles return if !self.config.clean_up? || !self.config.enabled? log "CloudTempfile.delete_expired_tempfiles is running..." # Delete expired temp files fog_files = (self.config.local?)? local_root.files : get_remote_files fog_files.each do |file| if file.last_modified <= Time.now.utc.ago(self.config.clean_up_older_than) delete_file(file) end end log "CloudTempfile.delete_expired_tempfiles is complete!" end |