From 17c8866d64c7af24c085d2c5aba01e0c444efdc0 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 17 Oct 2024 14:37:35 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20get=5Ffile=20ref=E7=A9=BA=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index b4628bff1..fbe79f27d 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -49,7 +49,8 @@ class AttachmentsController < ApplicationController url.gsub!(url.split("/")[-1], '') Rails.logger.info("url===#{url}") Rails.logger.info(filepath) - request_url = [domain, api_url, URI.encode(url), URI.escape(filepath), "?ref=#{URI.escape(ref.split('ref=')[1])}&access_token=#{User.where(admin: true).take&.gitea_token}"].join + ref = ref.blank? ? "" : URI.escape(ref.split('ref=')[1]) + request_url = [domain, api_url, URI.encode(url), URI.escape(filepath), "?ref=#{ref}&access_token=#{User.where(admin: true).take&.gitea_token}"].join Rails.logger.info("request_url===#{request_url}") file = Util.download_file(request_url, tmp_path) filename = filepath