Sha256: db5315658754de9414a13aa49c015c510e144668e4f1521bca757ba5b1f76fcc

Contents?: true

Size: 885 Bytes

Versions: 2

Compression:

Stored size: 885 Bytes

Contents

class IngestLocalFileJob < ActiveJob::Base
  attr_accessor :directory, :filename, :user_key, :file_set_id

  queue_as :ingest_local

  def perform(file_set_id, directory, filename, user_key)
    @file_set_id = file_set_id
    @directory = directory
    @filename = filename
    @user_key = user_key

    user = User.find_by_user_key(user_key)
    fail "Unable to find user for #{user_key}" unless user
    file_set = FileSet.find(file_set_id)
    file_set.label ||= filename
    path = File.join(directory, filename)

    actor = CurationConcerns::FileSetActor.new(file_set, user)

    if actor.create_content(File.open(path))
      FileUtils.rm(path)
      CurationConcerns.config.callback.run(:after_import_local_file_success, file_set, user, filename)
    else
      CurationConcerns.config.callback.run(:after_import_local_file_failure, file_set, user, filename)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
curation_concerns-models-0.3.0 app/jobs/ingest_local_file_job.rb
curation_concerns-models-0.2.0 app/jobs/ingest_local_file_job.rb