diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-03-13 00:55:49 +0000 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-03-15 21:49:01 +0000 |
commit | 1f5e809c047d9561fe03d04c51b1dc4fffd95e04 (patch) | |
tree | d8bd865e43e592e846adcc1a3de02e36c4fd982a /app/services/lfs | |
parent | ca66a04ffec2e311e72b5bdd2c68d3286ef6631c (diff) | |
download | gitlab-ce-1f5e809c047d9561fe03d04c51b1dc4fffd95e04.tar.gz |
Use correct encoding with Lfs::FileTransfromer
Diffstat (limited to 'app/services/lfs')
-rw-r--r-- | app/services/lfs/file_transformer.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/app/services/lfs/file_transformer.rb b/app/services/lfs/file_transformer.rb index bdb2f1bea42..69281ee3137 100644 --- a/app/services/lfs/file_transformer.rb +++ b/app/services/lfs/file_transformer.rb @@ -20,16 +20,26 @@ module Lfs @branch_name = branch_name end - def new_file(file_path, file_content) + def new_file(file_path, file_content, encoding: nil) if project.lfs_enabled? && lfs_file?(file_path) + file_content = Base64.decode64(file_content) if encoding == 'base64' lfs_pointer_file = Gitlab::Git::LfsPointerFile.new(file_content) lfs_object = create_lfs_object!(lfs_pointer_file, file_content) link_lfs_object!(lfs_object) - lfs_pointer_file.pointer + Result.new(content: lfs_pointer_file.pointer, encoding: 'text') else - file_content + Result.new(content: file_content, encoding: encoding) + end + end + + class Result + attr_reader :content, :encoding + + def initialize(content:, encoding:) + @content = content + @encoding = encoding end end |