Sha256: d91edb6e3a8172e939ccbd3dd0cf51a9803e8c8344e1fae02bf4611e1e73ae91

Contents?: true

Size: 916 Bytes

Versions: 89

Compression:

Stored size: 916 Bytes

Contents

# frozen_string_literal: true

require 'set'
require 'listen/error'

module Listen
  # @private api
  class Record
    class SymlinkDetector
      README_URL = 'https://github.com/guard/listen/blob/master/README.md'

      SYMLINK_LOOP_ERROR = <<-EOS
        ** ERROR: directory is already being watched! **

        Directory: %s

        is already being watched through: %s

        MORE INFO: #{README_URL}
      EOS

      Error = ::Listen::Error # for backward compatibility

      def initialize
        @real_dirs = Set.new
      end

      def verify_unwatched!(entry)
        real_path = entry.real_path
        @real_dirs.add?(real_path) or _fail(entry.sys_path, real_path)
      end

      private

      def _fail(symlinked, real_path)
        warn(format(SYMLINK_LOOP_ERROR, symlinked, real_path))
        raise ::Listen::Error::SymlinkLoop, 'Failed due to looped symlinks'
      end
    end
  end
end

Version data entries

89 entries across 89 versions & 6 rubygems

Version Path
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.2.9 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.2.8 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.2.7 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.2.6 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.2.5 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.2.4 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.2.3 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.2.2 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.2.1 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.2.0 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.1.99 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.1.98 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.1.97 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.1.96 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.1.95 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.1.94 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.1.93 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb
harbr-0.1.91 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/record/symlink_detector.rb