diff --git a/app/services/files/create_service.rb b/app/services/files/create_service.rb index 21065f715101615b37d2453cd48a33504caff038..3516cf30dbc8ee501067245df9574a523bc54fbc 100644 --- a/app/services/files/create_service.rb +++ b/app/services/files/create_service.rb @@ -33,23 +33,20 @@ module Files end end - if params[:encoding] == 'base64' - new_file_action = Gitlab::Satellite::NewFileAction.new(current_user, project, ref, file_path) - created_successfully = new_file_action.commit!( - params[:content], - params[:commit_message], - params[:encoding], - params[:new_branch] - ) - else - created_successfully = repository.commit_file( - current_user, - file_path, - params[:content], - params[:commit_message], - params[:new_branch] || ref - ) - end + content = + if params[:encoding] == 'base64' + Base64.decode64(params[:content]) + else + params[:content] + end + + created_successfully = repository.commit_file( + current_user, + file_path, + content, + params[:commit_message], + params[:new_branch] || ref + ) if created_successfully diff --git a/app/services/files/update_service.rb b/app/services/files/update_service.rb index 5efd43d16ceb3d5ad141733496282503050fb7c8..4d7ac3b7504786b8c5705ad9d5952012c8a757c2 100644 --- a/app/services/files/update_service.rb +++ b/app/services/files/update_service.rb @@ -19,23 +19,20 @@ module Files return error("You can only edit text files") end - if params[:encoding] == 'base64' - edit_file_action = Gitlab::Satellite::EditFileAction.new(current_user, project, ref, path) - edit_file_action.commit!( - params[:content], - params[:commit_message], - params[:encoding], - params[:new_branch] - ) - else - repository.commit_file( - current_user, - path, - params[:content], - params[:commit_message], - params[:new_branch] || ref - ) - end + content = + if params[:encoding] == 'base64' + Base64.decode64(params[:content]) + else + params[:content] + end + + repository.commit_file( + current_user, + path, + content, + params[:commit_message], + params[:new_branch] || ref + ) success rescue Gitlab::Satellite::CheckoutFailed => ex