fixed: 1.readme加载不正常, 2.文件目录加载性能优化

This commit is contained in:
xiaoxiaoqiong
2022-03-18 16:52:23 +08:00
parent 23dc2d7fb6
commit d9ae4e4ba0
3 changed files with 403 additions and 393 deletions

View File

@@ -1,4 +1,5 @@
if @project.forge?
is_dir = @sub_entries.is_a?(Array)
file_name = entry['name']
file_type = File.extname(file_name.to_s)[1..-1]
direct_download = download_type(file_type)
@@ -9,16 +10,16 @@ if @project.forge?
json.type entry['type']
json.size entry['size']
json.content (direct_download || image_type) ? nil : decode64_content(entry, @owner, @repository, @ref, @path)
json.content (direct_download || image_type || is_dir) ? nil : decode64_content(entry, @owner, @repository, @ref, @path)
json.target entry['target']
download_url =
if image_type
dir_path = [@owner.login, @repository.identifier, "raw/branch", @ref].join('/')
render_download_image_url(dir_path, entry['path'], decode64_content(entry, @owner, @repository, @ref))
is_dir ? "" : render_download_image_url(dir_path, entry['path'], decode64_content(entry, @owner, @repository, @ref))
else
# entry['download_url']
render_download_file_url(@owner, @repository, entry['path'].to_s, @ref)
is_dir ? "" : render_download_file_url(@owner, @repository, entry['path'].to_s, @ref)
end
json.download_url download_url