summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2018-03-13 00:55:49 +0000
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2018-03-15 21:49:01 +0000
commit1f5e809c047d9561fe03d04c51b1dc4fffd95e04 (patch)
treed8bd865e43e592e846adcc1a3de02e36c4fd982a /app/services
parentca66a04ffec2e311e72b5bdd2c68d3286ef6631c (diff)
downloadgitlab-ce-1f5e809c047d9561fe03d04c51b1dc4fffd95e04.tar.gz
Use correct encoding with Lfs::FileTransfromer
Diffstat (limited to 'app/services')
-rw-r--r--app/services/files/multi_service.rb5
-rw-r--r--app/services/lfs/file_transformer.rb16
2 files changed, 16 insertions, 5 deletions
diff --git a/app/services/files/multi_service.rb b/app/services/files/multi_service.rb
index be9c7c526a6..13a1dee4173 100644
--- a/app/services/files/multi_service.rb
+++ b/app/services/files/multi_service.rb
@@ -15,8 +15,9 @@ module Files
def actions_after_lfs_transformation(transformer, actions)
actions.map do |action|
if action[:action] == 'create'
- content = transformer.new_file(action[:file_path], action[:content])
- action[:content] = content
+ result = transformer.new_file(action[:file_path], action[:content], encoding: action[:encoding])
+ action[:content] = result.content
+ action[:encoding] = result.encoding
end
action
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