Class: ApprovedUploadSnapshot

Inherits:
BackgroundUploadSnapshot show all
Defined in:
app/models/approved_upload_snapshot.rb

Instance Attribute Summary

Attributes inherited from UploadSnapshot

#upload

Instance Method Summary collapse

Methods inherited from BackgroundUploadSnapshot

#existing_files, #mark_complete, #new_files, #prefix_filename, #upload_complete?

Methods inherited from UploadSnapshot

checksum_compare, #filenames, find_by_filename, #snapshot_deletions, #snapshot_modifications, #uri

Instance Method Details

#finalize_uploadObject



3
4
5
6
7
8
9
# File 'app/models/approved_upload_snapshot.rb', line 3

def finalize_upload
  new_files.each do |file|
    work.track_change(:added, file["filename"])
  end
  WorkActivity.add_work_activity(work.id, "#{new_files.count} #{'file'.pluralize(new_files.count)} were moved to the post curation bucket", new_files.first["user_id"],
                                 activity_type: WorkActivity::SYSTEM)
end

#store_files(s3_files, current_user: nil) ⇒ Object



11
12
13
14
15
16
17
# File 'app/models/approved_upload_snapshot.rb', line 11

def store_files(s3_files, current_user: nil)
  save # needed so I can reuse the code in backroundUploadSnapshot
  self.files = s3_files.map do |file|
    { "filename" => file.filename, "checksum" => file.checksum,
      "upload_status" => "started", user_id: current_user&.id, snapshot_id: id }
  end
end