Sha256: 4d36f81e87700baa329f6065649aa2dbdd3fd3beea28bf7bd684c23d75da0e88

Contents?: true

Size: 871 Bytes

Versions: 15

Compression:

Stored size: 871 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'.freeze

      SYMLINK_LOOP_ERROR = <<-EOS.freeze
        ** 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)
        STDERR.puts format(SYMLINK_LOOP_ERROR, symlinked, real_path)
        fail Error, 'Failed due to looped symlinks'
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
qiita_org-0.1.35 gems/ruby/2.7.0/gems/listen-3.3.1/lib/listen/record/symlink_detector.rb
qiita_org-0.1.34 gems/ruby/2.7.0/gems/listen-3.3.1/lib/listen/record/symlink_detector.rb
qiita_org-0.1.33 gems/ruby/2.7.0/gems/listen-3.3.1/lib/listen/record/symlink_detector.rb
qiita_org-0.1.32 gems/ruby/2.7.0/gems/listen-3.3.1/lib/listen/record/symlink_detector.rb
qiita_org-0.1.31 gems/ruby/2.7.0/gems/listen-3.3.1/lib/listen/record/symlink_detector.rb
qiita_org-0.1.30 gems/ruby/2.7.0/gems/listen-3.3.1/lib/listen/record/symlink_detector.rb
qiita_org-0.1.29 gems/ruby/2.7.0/gems/listen-3.3.1/lib/listen/record/symlink_detector.rb
qiita_org-0.1.28 gems/ruby/2.7.0/gems/listen-3.3.1/lib/listen/record/symlink_detector.rb
qiita_org-0.1.27 gems/ruby/2.7.0/gems/listen-3.3.1/lib/listen/record/symlink_detector.rb
qiita_org-0.1.26 gems/ruby/2.7.0/gems/listen-3.3.1/lib/listen/record/symlink_detector.rb
qiita_org-0.1.25 gems/ruby/2.7.0/gems/listen-3.3.1/lib/listen/record/symlink_detector.rb
listen-3.3.1 lib/listen/record/symlink_detector.rb
listen-3.3.0 lib/listen/record/symlink_detector.rb
listen-3.3.0.pre.3 lib/listen/record/symlink_detector.rb
listen-3.3.0.pre.2 lib/listen/record/symlink_detector.rb