instance method mirror

Ruby on Rails 7.0.10

Since v6.1.7.10

Available in: v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

mirror(key, checksum:)

Copy the file at the key from the primary service to each of the mirrors where it doesn’t already exist.

Parameters

key req
checksum keyreq
Source
# File activestorage/lib/active_storage/service/mirror_service.rb, line 54
    def mirror(key, checksum:)
      instrument :mirror, key: key, checksum: checksum do
        if (mirrors_in_need_of_mirroring = mirrors.select { |service| !service.exist?(key) }).any?
          primary.open(key, checksum: checksum) do |io|
            mirrors_in_need_of_mirroring.each do |service|
              io.rewind
              service.upload key, io, checksum: checksum
            end
          end
        end
      end
    end

Defined in activestorage/lib/active_storage/service/mirror_service.rb line 54 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveStorage::Service::MirrorService

Type at least 2 characters to search.

↑↓ navigate · open · esc close