Class: Hyrax::WorkingDirectory Deprecated

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/working_directory.rb

Overview

Deprecated.

Use JobIoWrapper instead

Class Method Summary collapse

Class Method Details

.copy_repository_resource_to_working_directory(file, id) ⇒ String

Returns path of the working file.

Parameters:

  • file (ActiveFedora::File)

    the resource in the repo

  • id (String)

    the identifier of the FileSet

Returns:

  • (String)

    path of the working file



25
26
27
28
29
# File 'app/services/hyrax/working_directory.rb', line 25

def copy_repository_resource_to_working_directory(file, id)
  Rails.logger.debug "Loading #{file.original_name} (#{file.id}) from the repository to the working directory"
  # TODO: this causes a load into memory, which we'd like to avoid
  copy_stream_to_working_directory(id, file.original_name, StringIO.new(file.content))
end

.find_or_retrieve(repository_file_id, id, filepath = nil) ⇒ String

Returns the file passed as filepath if that file exists. Otherwise it grabs the file from repository, puts it on the disk and returns that path.

Parameters:

  • repository_file_id (String)

    identifier for Hydra::PCDM::File

  • id (String)

    the identifier of the FileSet

  • filepath (String, NilClass) (defaults to: nil)

    path to existing cached copy of the file

Returns:

  • (String)

    path of the working file



11
12
13
14
15
16
17
18
19
20
# File 'app/services/hyrax/working_directory.rb', line 11

def find_or_retrieve(repository_file_id, id, filepath = nil)
  return filepath if filepath && File.exist?(filepath)
  repository_file = Hydra::PCDM::File.find(repository_file_id)
  working_path = full_filename(id, repository_file.original_name)
  if File.exist?(working_path)
    Rails.logger.debug "#{repository_file.original_name} already exists in the working directory at #{working_path}"
    return working_path
  end
  copy_repository_resource_to_working_directory(repository_file, id)
end