Class: Bulkrax::ValkyrieObjectFactory::FileFactoryInnerWorkings

Inherits:
FileFactory::InnerWorkings show all
Defined in:
app/factories/bulkrax/valkyrie_object_factory.rb

Instance Attribute Summary

Attributes inherited from FileFactory::InnerWorkings

#object_factory

Instance Method Summary collapse

Methods inherited from FileFactory::InnerWorkings

#destroy_existing_files, #file_attributes, #file_paths, #import_file, #import_files, #import_files_filenames, #initialize, #local_file_sets, #new_remote_files, #ordered_file_sets, #parsed_remote_files, #set_removed_filesets, #update_filesets, #upload_ids, #work_files_filenames

Methods included from Loggable

#log_created, #log_deleted_fs, #log_updated

Constructor Details

This class inherits a constructor from Bulkrax::FileFactory::InnerWorkings

Instance Method Details

#remove_file_set(file_set:) ⇒ Object



7
8
9
10
11
12
13
14
# File 'app/factories/bulkrax/valkyrie_object_factory.rb', line 7

def remove_file_set(file_set:)
   = Hyrax.custom_queries.find_files(file_set: file_set).first
  raise "No file metadata records found for #{file_set.class} ID=#{file_set.id}" unless 

  Hyrax::VersioningService.create(, user, File.new(Bulkrax.removed_image_path))

  ::ValkyrieCreateDerivativesJob.set(wait: 1.minute).perform_later(file_set.id, .id)
end

#update_file_set(file_set:, uploaded:) ⇒ NilClass

Replace an existing :file_set’s file with the :uploaded file.

Parameters:

  • file_set (Hyrax::FileSet, Object)
  • uploaded (Hyrax::UploadedFile)

Returns:

  • (NilClass)


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/factories/bulkrax/valkyrie_object_factory.rb', line 23

def update_file_set(file_set:, uploaded:)
   = Hyrax.custom_queries.find_files(file_set: file_set).first
  raise "No file metadata records found for #{file_set.class} ID=#{file_set.id}" unless 

  uploaded_file = uploaded.file

  # TODO: Is this accurate?  We'll need to interrogate the file_metadata
  # object.  Should it be `file_metadata.checksum.first.to_s` Or something
  # else?
  return nil if .checksum.first == Digest::SHA1.file(uploaded_file.path).to_s

  Hyrax::VersioningService.create(, user, uploaded_file)

  ::ValkyrieCreateDerivativesJob.set(wait: 1.minute).perform_later(file_set.id, .id)
  nil
end