Sha256: 83e3ef1e70d9ebad6c802327a42f5881e53155aa53b061d83d50f081e1ec9440

Contents?: true

Size: 852 Bytes

Versions: 6

Compression:

Stored size: 852 Bytes

Contents

# frozen_string_literal: true

require 'set'

module Listen
  # @private api
  class Record
    class SymlinkDetector
      WIKI = 'https://github.com/guard/listen/wiki/Duplicate-directory-errors'

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

        Directory: %s

        is already being watched through: %s

        MORE INFO: #{WIKI}
      EOS

      class Error < RuntimeError
      end

      def initialize
        @real_dirs = Set.new
      end

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

      private

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

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/listen-3.3.3/lib/listen/record/symlink_detector.rb
listen-3.4.0 lib/listen/record/symlink_detector.rb
listen-3.3.4 lib/listen/record/symlink_detector.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/listen-3.3.3/lib/listen/record/symlink_detector.rb
listen-3.3.3 lib/listen/record/symlink_detector.rb
listen-3.3.2 lib/listen/record/symlink_detector.rb