mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
gitea文件下载缓存,更改目录
This commit is contained in:
@@ -33,8 +33,9 @@ class AttachmentsController < ApplicationController
|
||||
normal_status(-1, "参数缺失") if params[:download_url].blank?
|
||||
url = base_url.starts_with?("https:") ? params[:download_url].to_s.gsub("http:", "https:") : params[:download_url].to_s
|
||||
md5_file = Base64.strict_encode64(params[:download_url])
|
||||
tmp_path = "#{Rails.root}/public/files/#{Time.now.strftime('%Y%m%d%')}-#{md5_file}"
|
||||
cache_key ="get_file:#{Time.now.strftime('%Y%m%d%')}:#{md5_file}"
|
||||
FileUtils.mkdir_p("#{Rails.root}#{EduSetting.get("attachment_folder")}gitea/") unless Dir.exists?("#{Rails.root}#{EduSetting.get("attachment_folder")}gitea/")
|
||||
tmp_path = "#{Rails.root}#{EduSetting.get("attachment_folder")}gitea/#{Time.now.strftime('%Y%m%d')}-#{md5_file}"
|
||||
cache_key ="get_file:#{Time.now.strftime('%Y%m%d')}:#{md5_file}"
|
||||
value = Rails.cache.read(cache_key)
|
||||
if value.to_i >= 5 && File.exist?(tmp_path)
|
||||
send_data(tmp_path, filename: filename, type: "application/octet-stream", disposition: 'attachment')
|
||||
|
||||
Reference in New Issue
Block a user