Method: OcflTools::OcflObject#update_file

Defined in:
lib/ocfl_tools/ocfl_object.rb

#update_file(file, digest, version) ⇒ Object

Note:

this method explicitly deletes the prior file if found, and re-creates it with a new digest via the #add_file method.

Updates an existing file with a new bitstream and digest.

Parameters:

  • filepath to update.

  • of updated file.

  • of object to update.



222
223
224
225
226
227
228
229
# File 'lib/ocfl_tools/ocfl_object.rb', line 222

def update_file(file, digest, version)
  # Same filename, different digest, update manifest.
  # Do a Delete, then an Add.
  existing_files = get_files(version)

  delete_file(file, version) if existing_files.key?(file)
  add_file(file, digest, version)
end