diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-01-11 23:12:34 +0000 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-03-15 02:39:08 +0000 |
commit | 1baac9211238f60d2d2a50cccd0bea6979bfa6ba (patch) | |
tree | 7f07f3d1eb65f31f01c52973d115d349a95e3de2 /app/services/files/multi_service.rb | |
parent | ffb1c65b0ba7fa8a4ea7e128cb47449f04837869 (diff) | |
download | gitlab-ce-1baac9211238f60d2d2a50cccd0bea6979bfa6ba.tar.gz |
Multi-file upload and Commit API obey LFS filters
Updates Files::MultiService for the commits API which is in turn used by the
multi-file upload web UI
Ensures that files which should be in LFS are transformed into LFS pointers
Uses Lfs::Transformer which then links LfsObjectProjects on success
Diffstat (limited to 'app/services/files/multi_service.rb')
-rw-r--r-- | app/services/files/multi_service.rb | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/app/services/files/multi_service.rb b/app/services/files/multi_service.rb index a03c59f569d..bd88c46e4af 100644 --- a/app/services/files/multi_service.rb +++ b/app/services/files/multi_service.rb @@ -3,11 +3,32 @@ module Files UPDATE_FILE_ACTIONS = %w(update move delete).freeze def create_commit! + Lfs::FileTransformer.link_lfs_objects(project, @branch_name) do |transformer| + actions = actions_after_lfs_transformation(transformer, params[:actions]) + + commit_actions!(actions) + end + end + + private + + 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 + end + + action + end + end + + def commit_actions!(actions) repository.multi_action( current_user, message: @commit_message, branch_name: @branch_name, - actions: params[:actions], + actions: actions, author_email: @author_email, author_name: @author_name, start_project: @start_project, @@ -17,8 +38,6 @@ module Files raise_error(e) end - private - def validate! super |