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
listen-3.7.1 lib/listen/record/symlink_detector.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/listen-3.7.0/lib/listen/record/symlink_detector.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/listen-3.7.0/lib/listen/record/symlink_detector.rb
listen-3.7.0 lib/listen/record/symlink_detector.rb
listen-3.6.0 lib/listen/record/symlink_detector.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/listen-3.5.1/lib/listen/record/symlink_detector.rb
listen-3.5.1 lib/listen/record/symlink_detector.rb
listen-3.5.0 lib/listen/record/symlink_detector.rb
listen-3.4.1 lib/listen/record/symlink_detector.rb