Method: Moab::StorageObjectVersion#ingest_dir

Defined in:
lib/moab/storage_object_version.rb

#ingest_dir(source_dir, target_dir, use_links = true) ⇒ void

This method returns an undefined value.

Returns recursively link or copy the source directory contents to the target directory.

Parameters:

  • source_dir (Pathname)

    The source location of the directory whose contents are to be ingested

  • target_dir (Pathname)

    The target location of the directory into which files are ingested

  • use_links (Boolean) (defaults to: true)

    If true, use hard links; if false, make copies

Raises:



157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/moab/storage_object_version.rb', line 157

def ingest_dir(source_dir, target_dir, use_links = true)
  raise(MoabRuntimeError, "cannot copy - target already exists: #{target_dir.expand_path}") if target_dir.exist?

  target_dir.mkpath
  source_dir.children.each do |child|
    if child.directory?
      ingest_dir(child, target_dir.join(child.basename), use_links)
    else
      ingest_file(child, target_dir, use_links)
    end
  end
end