2014-08-09 06:28:57 -04:00
|
|
|
class ExportCsv
|
|
|
|
|
|
|
|
def self.get_download_path(filename)
|
|
|
|
path = File.join(ExportCsv.base_directory, filename)
|
|
|
|
if File.exists?(path)
|
|
|
|
return path
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-08-14 16:17:52 -04:00
|
|
|
def self.remove_old_exports
|
2014-08-15 13:53:17 -04:00
|
|
|
if Dir.exists?(ExportCsv.base_directory)
|
2014-08-26 02:21:56 -04:00
|
|
|
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)
|
2014-08-15 13:53:17 -04:00
|
|
|
end
|
2014-08-14 16:17:52 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-08-09 06:28:57 -04:00
|
|
|
def self.base_directory
|
|
|
|
File.join(Rails.root, "public", "uploads", "csv_exports", RailsMultisite::ConnectionManagement.current_db)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|