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 def self.remove_old_exports
if Dir.exists?(ExportCsv.base_directory) if Dir.exists?(ExportCsv.base_directory)
dir = Dir.new(ExportCsv.base_directory) Dir.foreach(ExportCsv.base_directory) do |file|
dir.each do |file| path = File.join(ExportCsv.base_directory, file)
if (File.mtime(File.join(ExportCsv.base_directory, file)) < 2.days.ago) next if File.directory? path
File.delete(File.join(ExportCsv.base_directory, file))
if (File.mtime(path) < 2.days.ago)
File.delete(path)
end end
end end
end end