mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-29 18:46:23 -05:00
29 lines
671 B
Ruby
29 lines
671 B
Ruby
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
|
|
|
|
def self.remove_old_exports
|
|
if Dir.exists?(ExportCsv.base_directory)
|
|
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
|
|
end
|
|
|
|
def self.base_directory
|
|
File.join(Rails.root, "public", "uploads", "csv_exports", RailsMultisite::ConnectionManagement.current_db)
|
|
end
|
|
|
|
end
|