dev_course
SylorHuang 5 years ago
parent b3bda4ab65
commit 7f255328d7

@ -9,11 +9,13 @@ module GitHelper
# 版本库文件内容,带转码 # 版本库文件内容,带转码
def git_fle_content(repo_path, path) def git_fle_content(repo_path, path)
begin begin
content = GitService.file_content(repo_path: repo_path, path: path)["content"] content = GitService.file_content(repo_path: repo_path, path: path)
logger.info("@@@@@@@@@@@@@@@@@@#{content}")
logger.info("@@@@@@@@@@@@@@@@@@#{content}")
decode_content = nil decode_content = nil
if content.present? if content.present?
content = content["content"] #6.24 -hs 这个为新增,因为当实训题里含有选择题时,这里会报错,undefined method `[]' for nil:NilClass
content = Base64.decode64(content) content = Base64.decode64(content)
cd = CharDet.detect(content) cd = CharDet.detect(content)
logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}" logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}"
@ -27,6 +29,7 @@ module GitHelper
end end
decode_content decode_content
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
raise Educoder::TipException.new("文档内容获取异常") raise Educoder::TipException.new("文档内容获取异常")

Loading…
Cancel
Save