Class: Hyrax::RiiifFileResolver

Inherits:
Object
  • Object
show all
Includes:
ActiveSupport::Benchmarkable
Defined in:
lib/generators/hyrax/templates/config/initializers/riiif.rb

Instance Method Summary collapse

Instance Method Details

#file_locksConcurrent::Map<Concurrent::ReadWriteLock>

tracks individual file locks

Returns:

  • (Concurrent::Map<Concurrent::ReadWriteLock>)

See Also:



81
82
83
84
85
# File 'lib/generators/hyrax/templates/config/initializers/riiif.rb', line 81

def file_locks
  @file_locks ||= Concurrent::Map.new do |k, v|
    k.compute_if_absent(v) { Concurrent::ReadWriteLock.new }
  end
end

#find(id) ⇒ Riiif::File

Parameters:

  • id (String)

    from iiif manifest

Returns:

  • (Riiif::File)


69
70
71
72
73
74
75
76
# File 'lib/generators/hyrax/templates/config/initializers/riiif.rb', line 69

def find(id)
  path = nil
  file_locks[id].with_write_lock do
    path = build_path(id)
    path = build_path(id, force: true) unless File.exist?(path) # Ensures the file is locally available
  end
  RiiifFile.new(path, id: id)
end