Class: Hyrax::RiiifFileResolver
- Inherits:
-
Object
- Object
- Hyrax::RiiifFileResolver
- Includes:
- ActiveSupport::Benchmarkable
- Defined in:
- lib/generators/hyrax/templates/config/initializers/riiif.rb
Instance Method Summary collapse
-
#file_locks ⇒ Concurrent::Map<Concurrent::ReadWriteLock>
tracks individual file locks.
- #find(id) ⇒ Riiif::File
Instance Method Details
#file_locks ⇒ Concurrent::Map<Concurrent::ReadWriteLock>
tracks individual file locks
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
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 |