FIX: crashing job

This commit is contained in:
Sam 2014-08-26 16:21:56 +10:00
parent 95f9943d28
commit 1ccfb4fa20
1 changed files with 6 additions and 4 deletions

View File

@ -11,10 +11,12 @@ class ExportCsv
def self.remove_old_exports
if Dir.exists?(ExportCsv.base_directory)
dir = Dir.new(ExportCsv.base_directory)
dir.each do |file|
if (File.mtime(File.join(ExportCsv.base_directory, file)) < 2.days.ago)
File.delete(File.join(ExportCsv.base_directory, file))
Dir.foreach(ExportCsv.base_directory) do |file|
path = File.join(ExportCsv.base_directory, file)
next if File.directory? path
if (File.mtime(path) < 2.days.ago)
File.delete(path)
end
end
end