Skip to content

Commit

Permalink
Rubocop nitpicking
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorcorrea committed Oct 24, 2022
1 parent 144d9f4 commit c2e5541
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
18 changes: 12 additions & 6 deletions app/services/work_uploads_edit_service.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
# frozen_string_literal: true
class WorkUploadsEditService
attr_reader :work

def initialize(work, current_user)
@work = work
@current_user = current_user
@changes = []
end

def work
@work
end

# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
def update_precurated_file_list(work_params)
if work_params.key?(:deleted_uploads) || work_params.key?(:pre_curation_uploads) || work_params.key?(:replaced_uploads)
if work_params.key?(:deleted_uploads)
# delete the files indicated in the parameters
delete_pre_curation_uploads(work_params[:deleted_uploads])
elsif work_params.key?(:pre_curation_uploads)
# delete all existing uploads and then and then add the ones indicated in the parameters
# delete all existing uploads...
work.pre_curation_uploads.each do |existing_upload|
track_change(:deleted, existing_upload.filename.to_s)
existing_upload.purge
end
work.reload # reload the work to pick up the changes in the attachments

# ...reload the work to pick up the changes in the attachments
work.reload

# ...and then and then add the ones indicated in the parameters
Array(work_params[:pre_curation_uploads]).each do |new_upload|
track_change(:added, new_upload.original_filename)
work.pre_curation_uploads.attach(new_upload)
Expand All @@ -37,6 +41,8 @@ def update_precurated_file_list(work_params)
work
end
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength

def find_post_curation_uploads(upload_keys: [])
return [] unless work.approved? && !upload_keys.empty?
Expand Down
7 changes: 5 additions & 2 deletions config/storage.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
local: &local
service: 'Disk'
root: <%= Rails.root.join("storage") %>
service: 'S3'
access_key_id: <%= ENV['AWS_S3_KEY_ID'] || 'not-used-access_key_id' %>
secret_access_key: <%= ENV['AWS_S3_SECRET_KEY'] || 'not-used-secret_access_key' %>
region: <%= S3QueryService.pre_curation_config.fetch(:region) %>
bucket: <%= S3QueryService.pre_curation_config.fetch(:bucket) %>

development: &development
<<: *local
Expand Down

0 comments on commit c2e5541

Please sign in to comment.